zoukankan      html  css  js  c++  java
  • 取得一个对象的具体类型

     public static string GetType(object source)
     {
        if (source == null)   

           {
                    return "null";
            }

                var type = source.GetType();
                switch (Type.GetTypeCode(type))
                {
                    //数值型
                    case TypeCode.Byte:
                    case TypeCode.Decimal:
                    case TypeCode.Double:
                    case TypeCode.Int16:
                    case TypeCode.Int32:
                    case TypeCode.Int64:
                    case TypeCode.SByte:
                    case TypeCode.Single:
                    case TypeCode.UInt16:
                    case TypeCode.UInt32:
                    case TypeCode.UInt64:
                        return source.ToString();
                    case TypeCode.Object:
                        break;
                    case TypeCode.Boolean:
                        return (bool)source ? "true" : "false";
                    case TypeCode.DBNull:
                        return "null";
                    default:
                        return "\"" + source + "\"";
                }

    }

  • 相关阅读:
    Chromium GN构建工具的使用
    cef 不更新编译
    Debugging SSL on Linux
    chromium url 请求流程
    mim
    qt打包发布问题 缺失qt动态库
    qmake生成pro的make总失败。但是qt creator里面是好的
    qt 与 x11 头文件同时引用
    Ubuntu16安装GTK+2.0教程
    gcc编译静态库到自己的程序 解决在不同linux下因libc版本问题而不能运行 版本兼容问题
  • 原文地址:https://www.cnblogs.com/wangsx/p/2205694.html
Copyright © 2011-2022 走看看