• 取得一个对象的具体类型


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

    }

  • 相关阅读:
    Redis数据类型之字符串String
    Redis数据类型之列表List
    hdu 2066 一个人的旅行
    CDOJ 1221 Ancient Go
    如何避免javascript中的冲突
    利用锚点制作简单索引效果
    函数中的私有变量和特权方法
    Linux中常用命令cat
    java -jar参数运行方式设置classpath
    Linux中的数据重定向
  • 原文地址:https://www.cnblogs.com/wangsx/p/2205694.html
Copyright © 2020-2023  润新知