当前位置: 首页>>代码示例>>C#>>正文


C# IConvertible.ToDecimal方法代码示例

本文整理汇总了C#中IConvertible.ToDecimal方法的典型用法代码示例。如果您正苦于以下问题:C# IConvertible.ToDecimal方法的具体用法?C# IConvertible.ToDecimal怎么用?C# IConvertible.ToDecimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConvertible的用法示例。


在下文中一共展示了IConvertible.ToDecimal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddDecimal

 private static object AddDecimal(IConvertible Left, IConvertible Right)
 {
     decimal num = Left.ToDecimal(null);
     decimal num2 = Right.ToDecimal(null);
     try
     {
         return decimal.Add(num, num2);
     }
     catch (OverflowException)
     {
         return (Convert.ToDouble(num) + Convert.ToDouble(num2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:Operators.cs

示例2: AddDecimal

 private static object AddDecimal(IConvertible conv1, IConvertible conv2)
 {
     decimal num;
     if (conv1 != null)
     {
         num = conv1.ToDecimal(null);
     }
     decimal num2 = conv2.ToDecimal(null);
     try
     {
         return decimal.Add(num, num2);
     }
     catch (OverflowException)
     {
         return (Convert.ToDouble(num) + Convert.ToDouble(num2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ObjectType.cs

示例3: ToUint32

        internal static uint ToUint32(object value, IConvertible ic)
        {
            switch (GetTypeCode(value, ic))
            {
                case TypeCode.Empty:
                    return 0;

                case TypeCode.Object:
                case TypeCode.DateTime:
                {
                    object obj2 = ToPrimitive(value, PreferredType.Number, ref ic);
                    if (obj2 == value)
                    {
                        return 0;
                    }
                    return ToUint32(obj2, ic);
                }
                case TypeCode.DBNull:
                    return 0;

                case TypeCode.Boolean:
                    if (ic.ToBoolean(null))
                    {
                        return 1;
                    }
                    return 0;

                case TypeCode.Char:
                    return ic.ToChar(null);

                case TypeCode.SByte:
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                    return (uint) ic.ToInt64(null);

                case TypeCode.Byte:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                    return ic.ToUInt32(null);

                case TypeCode.UInt64:
                    return (uint) ic.ToUInt64(null);

                case TypeCode.Single:
                case TypeCode.Double:
                    return (uint) Runtime.DoubleToInt64(ic.ToDouble(null));

                case TypeCode.Decimal:
                    return (uint) Runtime.UncheckedDecimalToInt64(ic.ToDecimal(null));

                case TypeCode.String:
                    return (uint) Runtime.DoubleToInt64(ToNumber(ic.ToString(null)));
            }
            return 0;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:56,代码来源:Convert.cs

示例4: SetAsIConvertible

        public void SetAsIConvertible(IConvertible value) {
            Debug.Assert(IsEmpty); // The setter can only be called once as VariantClear might be needed otherwise

            TypeCode tc = value.GetTypeCode();
            CultureInfo ci = CultureInfo.CurrentCulture;

            switch (tc) {
                case TypeCode.Empty: break;
                case TypeCode.Object: AsUnknown = value; break;
                case TypeCode.DBNull: SetAsNull(); break;
                case TypeCode.Boolean: AsBool = value.ToBoolean(ci); break;
                case TypeCode.Char: AsUi2 = value.ToChar(ci); break;
                case TypeCode.SByte: AsI1 = value.ToSByte(ci); break;
                case TypeCode.Byte: AsUi1 = value.ToByte(ci); break;
                case TypeCode.Int16: AsI2 = value.ToInt16(ci); break;
                case TypeCode.UInt16: AsUi2 = value.ToUInt16(ci); break;
                case TypeCode.Int32: AsI4 = value.ToInt32(ci); break;
                case TypeCode.UInt32: AsUi4 = value.ToUInt32(ci); break;
                case TypeCode.Int64: AsI8 = value.ToInt64(ci); break;
                case TypeCode.UInt64: AsI8 = value.ToInt64(ci); break;
                case TypeCode.Single: AsR4 = value.ToSingle(ci); break;
                case TypeCode.Double: AsR8 = value.ToDouble(ci); break;
                case TypeCode.Decimal: AsDecimal = value.ToDecimal(ci); break;
                case TypeCode.DateTime: AsDate = value.ToDateTime(ci); break;
                case TypeCode.String: AsBstr = value.ToString(ci); break;

                default:
                    throw Assert.Unreachable;
            }
        }
开发者ID:andreakn,项目名称:ironruby,代码行数:30,代码来源:Variant.cs

示例5: ToBoolean

 internal static bool ToBoolean(Object value, IConvertible ic){
   switch (Convert.GetTypeCode(value, ic)){
     case TypeCode.Empty: return false;
     case TypeCode.Object:
       if (value is Missing || value is System.Reflection.Missing) return false;
       Type t = value.GetType();
       MethodInfo meth = t.GetMethod("op_True", BindingFlags.ExactBinding|BindingFlags.Public|BindingFlags.Static, null, new Type[]{t}, null);
       if (meth != null && (meth.Attributes & MethodAttributes.SpecialName) != 0 && meth.ReturnType == Typeob.Boolean){
         meth = new JSMethodInfo(meth);
         return (bool)meth.Invoke(null, BindingFlags.SuppressChangeType, null, new Object[]{value}, null);
       }
       return true;
     case TypeCode.DBNull: return false;
     case TypeCode.Boolean: return ic.ToBoolean(null);
     case TypeCode.Char: return ic.ToChar(null) != (Char)0;
     case TypeCode.SByte:
     case TypeCode.Byte:
     case TypeCode.Int16:
     case TypeCode.UInt16:
     case TypeCode.Int32: return ic.ToInt32(null) != 0;
     case TypeCode.UInt32:
     case TypeCode.Int64: return ic.ToInt64(null) != 0;
     case TypeCode.UInt64: return ic.ToUInt64(null) != 0;
     case TypeCode.Single:
     case TypeCode.Double:
       double d = ic.ToDouble(null);
       if (d != d) return false; else return d != 0;
     case TypeCode.Decimal: return ic.ToDecimal(null) != (Decimal)0;
     case TypeCode.DateTime: return true;
     case TypeCode.String: return ic.ToString(null).Length != 0;
   }
   return false; //should never get here
 }
开发者ID:ArildF,项目名称:masters,代码行数:33,代码来源:convert.cs

示例6: DoAddOvf

 public static Literal DoAddOvf(IConvertible ic1, IConvertible ic2, TypeCode code1, TypeCode code2, BinaryExpression binaryExpression){
   TypeNode type = SystemTypes.Object;
   object val = null;
   checked{switch(code1){
     case TypeCode.SByte:
     case TypeCode.Int16:
     case TypeCode.Int32:
       int i = ic1.ToInt32(null);
       switch(code2){
         case TypeCode.SByte:
         case TypeCode.Int16:
         case TypeCode.Int32: 
         case TypeCode.Byte:
         case TypeCode.Char:
         case TypeCode.UInt16:
           val = i + ic2.ToInt32(null); 
           type = SystemTypes.Int32;
           break;
         case TypeCode.Int64: 
         case TypeCode.UInt32: 
         case TypeCode.UInt64: 
           val = i + ic2.ToInt64(null); 
           type = SystemTypes.Int64;
           break;
         case TypeCode.Single: 
           val = i + ic2.ToSingle(null); 
           type = SystemTypes.Single;
           break;
         case TypeCode.Double: 
           val = i + ic2.ToDouble(null); 
           type = SystemTypes.Double;
           break;
         case TypeCode.Decimal:
           val = i + ic2.ToDecimal(null);
           type = SystemTypes.Decimal;
           break;
         default: return null;
       }
       break;
     case TypeCode.Byte:
     case TypeCode.UInt16:
       ushort us = ic1.ToUInt16(null);
       switch(code2){
         case TypeCode.SByte:
         case TypeCode.Int16:
         case TypeCode.Int32: 
           val = us + ic2.ToInt32(null); 
           type = SystemTypes.Int32;
           break;
         case TypeCode.Byte:
         case TypeCode.UInt16:
         case TypeCode.Char:
         case TypeCode.UInt32: 
           val = us + ic2.ToUInt32(null); 
           type = SystemTypes.UInt32;
           break;
         case TypeCode.Int64: 
           val = us + ic2.ToInt64(null); 
           type = SystemTypes.Int64;
           break;
         case TypeCode.UInt64: 
           val = us + ic2.ToUInt64(null); 
           type = SystemTypes.UInt64;
           break;
         case TypeCode.Single: 
           val = us + ic2.ToSingle(null); 
           type = SystemTypes.Single;
           break;
         case TypeCode.Double: 
           val = us + ic2.ToDouble(null); 
           type = SystemTypes.Double;
           break;
         case TypeCode.Decimal:
           val = us + ic2.ToDecimal(null);
           type = SystemTypes.Decimal;
           break;
         default: return null;
       }
       break;
     case TypeCode.UInt32:
       uint ui = ic1.ToUInt32(null);
       switch(code2){
         case TypeCode.SByte:
         case TypeCode.Int16:
         case TypeCode.Int32: 
         case TypeCode.Int64: 
           val = ui + ic2.ToInt64(null); 
           type = SystemTypes.Int64;
           break;
         case TypeCode.Byte:
         case TypeCode.UInt16:
         case TypeCode.Char:
         case TypeCode.UInt32: 
           val = ui + ic2.ToUInt32(null); 
           type = SystemTypes.UInt32;
           break;
         case TypeCode.UInt64: 
           val = ui + ic2.ToUInt64(null); 
           type = SystemTypes.UInt64;
           break;
//.........这里部分代码省略.........
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:101,代码来源:Evaluator.cs

示例7: DefaultToType

		internal static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
		{
			if (targetType == null)
			{
				throw new ArgumentNullException("targetType");
			}
			RuntimeType left = targetType as RuntimeType;
			if (left != null)
			{
				if (value.GetType() == targetType)
				{
					return value;
				}
				if (left == Convert.ConvertTypes[3])
				{
					return value.ToBoolean(provider);
				}
				if (left == Convert.ConvertTypes[4])
				{
					return value.ToChar(provider);
				}
				if (left == Convert.ConvertTypes[5])
				{
					return value.ToSByte(provider);
				}
				if (left == Convert.ConvertTypes[6])
				{
					return value.ToByte(provider);
				}
				if (left == Convert.ConvertTypes[7])
				{
					return value.ToInt16(provider);
				}
				if (left == Convert.ConvertTypes[8])
				{
					return value.ToUInt16(provider);
				}
				if (left == Convert.ConvertTypes[9])
				{
					return value.ToInt32(provider);
				}
				if (left == Convert.ConvertTypes[10])
				{
					return value.ToUInt32(provider);
				}
				if (left == Convert.ConvertTypes[11])
				{
					return value.ToInt64(provider);
				}
				if (left == Convert.ConvertTypes[12])
				{
					return value.ToUInt64(provider);
				}
				if (left == Convert.ConvertTypes[13])
				{
					return value.ToSingle(provider);
				}
				if (left == Convert.ConvertTypes[14])
				{
					return value.ToDouble(provider);
				}
				if (left == Convert.ConvertTypes[15])
				{
					return value.ToDecimal(provider);
				}
				if (left == Convert.ConvertTypes[16])
				{
					return value.ToDateTime(provider);
				}
				if (left == Convert.ConvertTypes[18])
				{
					return value.ToString(provider);
				}
				if (left == Convert.ConvertTypes[1])
				{
					return value;
				}
				if (left == Convert.EnumType)
				{
					return (Enum)value;
				}
				if (left == Convert.ConvertTypes[2])
				{
					throw new InvalidCastException(Environment.GetResourceString("InvalidCast_DBNull"));
				}
				if (left == Convert.ConvertTypes[0])
				{
					throw new InvalidCastException(Environment.GetResourceString("InvalidCast_Empty"));
				}
			}
			throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", new object[]
			{
				value.GetType().FullName, 
				targetType.FullName
			}));
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:96,代码来源:Convert.cs

示例8: JScriptStrictEquals

        internal static bool JScriptStrictEquals(object v1, object v2, IConvertible ic1, IConvertible ic2, TypeCode t1, TypeCode t2, bool checkForDebuggerObjects)
        {
            long num7;
            switch (t1)
            {
                case TypeCode.Empty:
                    return (t2 == TypeCode.Empty);

                case TypeCode.Object:
                    if (v1 != v2)
                    {
                        if ((v1 is Microsoft.JScript.Missing) || (v1 is System.Reflection.Missing))
                        {
                            v1 = null;
                        }
                        if (v1 == v2)
                        {
                            return true;
                        }
                        if ((v2 is Microsoft.JScript.Missing) || (v2 is System.Reflection.Missing))
                        {
                            v2 = null;
                        }
                        if (checkForDebuggerObjects)
                        {
                            IDebuggerObject obj2 = v1 as IDebuggerObject;
                            if (obj2 != null)
                            {
                                IDebuggerObject o = v2 as IDebuggerObject;
                                if (o != null)
                                {
                                    return obj2.IsEqual(o);
                                }
                            }
                        }
                        return (v1 == v2);
                    }
                    return true;

                case TypeCode.DBNull:
                    return (t2 == TypeCode.DBNull);

                case TypeCode.Boolean:
                    if (t2 != TypeCode.Boolean)
                    {
                        return false;
                    }
                    return (ic1.ToBoolean(null) == ic2.ToBoolean(null));

                case TypeCode.Char:
                {
                    char ch = ic1.ToChar(null);
                    switch (t2)
                    {
                        case TypeCode.Char:
                            return (ch == ic2.ToChar(null));

                        case TypeCode.SByte:
                        case TypeCode.Byte:
                        case TypeCode.Int16:
                        case TypeCode.UInt16:
                        case TypeCode.Int32:
                        case TypeCode.UInt32:
                        case TypeCode.Int64:
                            return (ch == ic2.ToInt64(null));

                        case TypeCode.UInt64:
                            return (ch == ic2.ToUInt64(null));

                        case TypeCode.Single:
                        case TypeCode.Double:
                            return (((double) ch) == ic2.ToDouble(null));

                        case TypeCode.Decimal:
                            return (ch == ic2.ToDecimal(null));

                        case TypeCode.String:
                        {
                            string str = ic2.ToString(null);
                            return ((str.Length == 1) && (ch == str[0]));
                        }
                    }
                    break;
                }
                case TypeCode.SByte:
                {
                    sbyte num = ic1.ToSByte(null);
                    switch (t2)
                    {
                        case TypeCode.Char:
                            return (num == ic2.ToChar(null));

                        case TypeCode.SByte:
                        case TypeCode.Byte:
                        case TypeCode.Int16:
                        case TypeCode.UInt16:
                        case TypeCode.Int32:
                        case TypeCode.UInt32:
                        case TypeCode.Int64:
                            return (num == ic2.ToInt64(null));
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:StrictEquality.cs

示例9: JScriptCompare2

      private static double JScriptCompare2(Object v1, Object v2, IConvertible ic1, IConvertible ic2, TypeCode t1, TypeCode t2){
        if (t1 == TypeCode.Object){
          v1 = Convert.ToPrimitive(v1, PreferredType.Number, ref ic1);
          t1 = Convert.GetTypeCode(v1, ic1);
        }
        if (t2 == TypeCode.Object){
          v2 = Convert.ToPrimitive(v2, PreferredType.Number, ref ic2);
          t2 = Convert.GetTypeCode(v2, ic2);
        }
        switch (t1){
          case TypeCode.Char:
            if (t2 == TypeCode.String) return String.CompareOrdinal(Convert.ToString(v1, ic1), ic2.ToString(null));
            goto case TypeCode.UInt16;

          case TypeCode.SByte:
          case TypeCode.Byte:
          case TypeCode.Int16:
          case TypeCode.UInt16:
          case TypeCode.Int32:
          case TypeCode.UInt32:
          case TypeCode.Int64:
            long l = ic1.ToInt64(null);
            switch (t2){
              case TypeCode.SByte:
              case TypeCode.Byte:
              case TypeCode.Int16:
              case TypeCode.UInt16:
              case TypeCode.Int32:
              case TypeCode.UInt32:
              case TypeCode.Int64:
                return l - ic2.ToInt64(null);
              case TypeCode.UInt64:
                if (l < 0) return -1;
                ulong ul2 = ic2.ToUInt64(null);
                if (((ulong)l) < ul2) return -1;
                if (((ulong)l) == ul2) return 0;
                return 1;
              case TypeCode.Single:
              case TypeCode.Double:
                return ((double)l) - ic2.ToDouble(null);
              case TypeCode.Decimal:
                return (double)(new Decimal(l) - ic2.ToDecimal(null));
              default:
                Object bd2 = Convert.ToNumber(v2, ic2);
                return JScriptCompare2(v1, bd2, ic1, Convert.GetIConvertible(bd2), t1, TypeCode.Double);
            }

          case TypeCode.UInt64:
            ulong ul = ic1.ToUInt64(null);
            switch (t2){
              case TypeCode.SByte:
              case TypeCode.Byte:
              case TypeCode.Int16:
              case TypeCode.UInt16:
              case TypeCode.Int32:
              case TypeCode.UInt32:
              case TypeCode.Int64:
                long l2 = ic2.ToInt64(null);
                if (l2 < 0) return 1;
                if (ul == (ulong)l2) return 0;
                return -1;
              case TypeCode.UInt64:
                ulong ul2 = ic2.ToUInt64(null);
                if (ul < ul2) return -1;
                if (ul == ul2) return 0;
                return 1;
              case TypeCode.Single:
              case TypeCode.Double:
                return ((double)ul) - ic2.ToDouble(null);
              case TypeCode.Decimal:
                return (double)(new Decimal(ul) - ic2.ToDecimal(null));
              default:
                Object bd2 = Convert.ToNumber(v2, ic2);
                return JScriptCompare2(v1, bd2, ic1, Convert.GetIConvertible(bd2), t1, TypeCode.Double);
            }

          case TypeCode.Decimal:
            Decimal dec1 = ic1.ToDecimal(null);
            switch (t2){
              case TypeCode.SByte:
              case TypeCode.Byte:
              case TypeCode.Int16:
              case TypeCode.UInt16:
              case TypeCode.Int32:
              case TypeCode.UInt32:
              case TypeCode.Int64:
                return (double)(dec1 - new Decimal(ic2.ToInt64(null)));
              case TypeCode.UInt64:
                return (double)(dec1 - new Decimal(ic2.ToUInt64(null)));
              case TypeCode.Single:
              case TypeCode.Double:
                return (double)(dec1 - new Decimal(ic2.ToDouble(null)));
              case TypeCode.Decimal:
                return (double)(dec1 - ic2.ToDecimal(null));
              default:
                return (double)(dec1 - new Decimal(Convert.ToNumber(v2, ic2)));
            }

          case TypeCode.String:
            switch (t2){
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:relational.cs

示例10: DecimalToInteger

 private static int DecimalToInteger(IConvertible ValueInterface)
 {
     return Convert.ToInt32(ValueInterface.ToDecimal(null));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:IntegerType.cs

示例11: ModDecimal

 private static object ModDecimal(IConvertible Left, IConvertible Right)
 {
     decimal num = Left.ToDecimal(null);
     decimal num2 = Right.ToDecimal(null);
     return decimal.Remainder(num, num2);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:6,代码来源:Operators.cs

示例12: DivideDecimal

 private static object DivideDecimal(IConvertible Left, IConvertible Right)
 {
     decimal num = Left.ToDecimal(null);
     decimal num2 = Right.ToDecimal(null);
     try
     {
         return decimal.Divide(num, num2);
     }
     catch (OverflowException)
     {
         return (Convert.ToSingle(num) / Convert.ToSingle(num2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:Operators.cs

示例13: CompareDecimal

 private static CompareClass CompareDecimal(IConvertible Left, IConvertible Right)
 {
     int num = decimal.Compare(Left.ToDecimal(null), Right.ToDecimal(null));
     if (num == 0)
     {
         return CompareClass.Equal;
     }
     if (num > 0)
     {
         return CompareClass.Greater;
     }
     return CompareClass.Less;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:Operators.cs

示例14: DecimalToBoolean

 private static bool DecimalToBoolean(IConvertible ValueInterface)
 {
     return Convert.ToBoolean(ValueInterface.ToDecimal(null));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:BooleanType.cs

示例15: JScriptStrictEquals

 internal static bool JScriptStrictEquals(Object v1, Object v2, IConvertible ic1, IConvertible ic2, TypeCode t1, TypeCode t2, bool checkForDebuggerObjects){
   switch (t1){
     case TypeCode.Empty: return t2 == TypeCode.Empty;
     case TypeCode.Object:
       if (v1 == v2) return true;
       if (v1 is Missing || v1 is System.Reflection.Missing) v1 = null;
       if (v1 == v2) return true;
       if (v2 is Missing || v2 is System.Reflection.Missing) v2 = null;
       return v1 == v2;
     case TypeCode.DBNull: return t2 == TypeCode.DBNull;
     case TypeCode.Boolean: return t2 == TypeCode.Boolean && ic1.ToBoolean(null) == ic2.ToBoolean(null);
     
     case TypeCode.Char: 
       Char ch = ic1.ToChar(null);
       switch(t2){
         case TypeCode.Char: return ch == ic2.ToChar(null);
         case TypeCode.SByte:
         case TypeCode.Byte:
         case TypeCode.Int16:
         case TypeCode.UInt16:
         case TypeCode.Int32:
         case TypeCode.UInt32:
         case TypeCode.Int64: return ch == ic2.ToInt64(null);
         case TypeCode.UInt64: return ch == ic2.ToUInt64(null);
         case TypeCode.Single: 
         case TypeCode.Double: return ch == ic2.ToDouble(null);
         case TypeCode.Decimal: return ((Decimal)(int)ch) == ic2.ToDecimal(null);
         case TypeCode.String:
           String str = ic2.ToString(null);
           return str.Length == 1 && ch == str[0];
       }
       return false;
     
     case TypeCode.SByte:
       SByte sb1 = ic1.ToSByte(null);
       switch (t2){
         case TypeCode.Char: return sb1 == ic2.ToChar(null);
         case TypeCode.SByte:
         case TypeCode.Byte:
         case TypeCode.Int16:
         case TypeCode.UInt16:
         case TypeCode.Int32:
         case TypeCode.UInt32:
         case TypeCode.Int64: return sb1 == ic2.ToInt64(null);
         case TypeCode.UInt64: return sb1 >= 0 && ((UInt64)sb1) == ic2.ToUInt64(null);
         case TypeCode.Single: return sb1 == ic2.ToSingle(null);
         case TypeCode.Double: return sb1 == ic2.ToDouble(null);
         case TypeCode.Decimal: return ((Decimal)sb1) == ic2.ToDecimal(null);
       }
       return false;
       
     case TypeCode.Byte:
       Byte b1 = ic1.ToByte(null);
       switch (t2){
         case TypeCode.Char: return b1 == ic2.ToChar(null);
         case TypeCode.SByte:
         case TypeCode.Byte:
         case TypeCode.Int16:
         case TypeCode.UInt16:
         case TypeCode.Int32:
         case TypeCode.UInt32:
         case TypeCode.Int64: return b1 == ic2.ToInt64(null);
         case TypeCode.UInt64: return b1 == ic2.ToUInt64(null);
         case TypeCode.Single: return b1 == ic2.ToSingle(null);
         case TypeCode.Double: return b1 == ic2.ToDouble(null);
         case TypeCode.Decimal: return ((Decimal)b1) == ic2.ToDecimal(null);
       }
       return false;
       
     case TypeCode.Int16:
       Int16 s1 = ic1.ToInt16(null);
       switch (t2){
         case TypeCode.Char: return s1 == ic2.ToChar(null);
         case TypeCode.SByte:
         case TypeCode.Byte:
         case TypeCode.Int16:
         case TypeCode.UInt16:
         case TypeCode.Int32:
         case TypeCode.UInt32:
         case TypeCode.Int64: return s1 == ic2.ToInt64(null);
         case TypeCode.UInt64: return s1 >= 0 && ((UInt64)s1) == ic2.ToUInt64(null);
         case TypeCode.Single: return s1 == ic2.ToSingle(null);
         case TypeCode.Double: return s1 == ic2.ToDouble(null);
         case TypeCode.Decimal: return ((Decimal)s1) == ic2.ToDecimal(null);
      }
       return false;
       
     case TypeCode.UInt16:
       UInt16 us1 = ic1.ToUInt16(null);
       switch (t2){
         case TypeCode.Char: return us1 == ic2.ToChar(null);
         case TypeCode.SByte:
         case TypeCode.Byte:
         case TypeCode.Int16:
         case TypeCode.UInt16:
         case TypeCode.Int32:
         case TypeCode.UInt32:
         case TypeCode.Int64: return us1 == ic2.ToInt64(null);
         case TypeCode.UInt64: return us1 == ic2.ToUInt64(null);
         case TypeCode.Single: return us1 == ic2.ToSingle(null);
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:strictequality.cs


注:本文中的IConvertible.ToDecimal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。