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

    }

  • 相关阅读:
    正向代理和反向代理
    python的reduce,map,zip,filter和sorted函数
    sed和awk的简单使用
    nginx+uWSGI+django+virtualenv+supervisor发布web服务器
    nginx负载均衡
    nginx入门与实战
    python开发之virtualenv与virtualenvwrapper讲解
    Linux下的python3,virtualenv,Mysql、nginx、redis安装配置
    Linux系统基础优化及常用命令
    vim与程序员
  • 原文地址:https://www.cnblogs.com/wangsx/p/2205694.html
Copyright © 2011-2022 走看看