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 + "\"";
                }

    }

  • 相关阅读:
    php header
    How to Share a Theme With All Users in a Windows 7 Computer?
    240多个jQuery插件
    Delphi读写UTF8、Unicode格式文本文件
    虚拟网关解决ARP批处理版
    从煎蛋网上抓取妹子图
    在【批处理】中过滤特殊字符
    反序列化(临时)
    python发邮件实例
    反序列化(临时)
  • 原文地址:https://www.cnblogs.com/wangsx/p/2205694.html
Copyright © 2011-2022 走看看