ToUInt16() 개인적인 메소드

private ToUInt16 ( string s ) : UInt16
s string
리턴 System.UInt16
예제 #1
0
        internal static object StringToObject(Type type, string value)
        {
            if (value == null || value == String.Empty)
            {
                return(DBNull.Value);
            }

            switch (Type.GetTypeCode(type))
            {
            case TypeCode.Boolean: return(XmlConvert.ToBoolean(value));

            case TypeCode.Byte: return(XmlConvert.ToByte(value));

            case TypeCode.Char: return((char)XmlConvert.ToInt32(value));

#if NET_2_0
            case TypeCode.DateTime: return(XmlConvert.ToDateTime(value, XmlDateTimeSerializationMode.Unspecified));
#else
            case TypeCode.DateTime: return(XmlConvert.ToDateTime(value));
#endif
            case TypeCode.Decimal: return(XmlConvert.ToDecimal(value));

            case TypeCode.Double: return(XmlConvert.ToDouble(value));

            case TypeCode.Int16: return(XmlConvert.ToInt16(value));

            case TypeCode.Int32: return(XmlConvert.ToInt32(value));

            case TypeCode.Int64: return(XmlConvert.ToInt64(value));

            case TypeCode.SByte: return(XmlConvert.ToSByte(value));

            case TypeCode.Single: return(XmlConvert.ToSingle(value));

            case TypeCode.UInt16: return(XmlConvert.ToUInt16(value));

            case TypeCode.UInt32: return(XmlConvert.ToUInt32(value));

            case TypeCode.UInt64: return(XmlConvert.ToUInt64(value));
            }

            if (type == typeof(TimeSpan))
            {
                return(XmlConvert.ToTimeSpan(value));
            }
            if (type == typeof(Guid))
            {
                return(XmlConvert.ToGuid(value));
            }
            if (type == typeof(byte[]))
            {
                return(Convert.FromBase64String(value));
            }

            return(Convert.ChangeType(value, type));
        }
예제 #2
0
 public static UInt16 StringToUnsignedShort(string value)
 {
     return(XmlConvert.ToUInt16(value));
 }