AT.MIN.Tools.ToInteger C# (CSharp) Méthode

ToInteger() public static méthode

Converts the specified values boxed type to its correpsonding integer type.
public static ToInteger ( object Value, bool Round ) : object
Value object The value.
Round bool
Résultat object
		public static object ToInteger( object Value, bool Round )
		{
			switch ( Type.GetTypeCode( Value.GetType() ) )
			{
				case TypeCode.SByte:
					return Value;
				case TypeCode.Int16:
					return Value;
				case TypeCode.Int32:
					return Value;
				case TypeCode.Int64:
					return Value;

				case TypeCode.Byte:
					return Value;
				case TypeCode.UInt16:
					return Value;
				case TypeCode.UInt32:
					return Value;
				case TypeCode.UInt64:
					return Value;

				case TypeCode.Single:
					return ( Round ? (int)Math.Round( (float)Value ) : (int)( (float)Value ) );
				case TypeCode.Double:
					return ( Round ? (long)Math.Round( (double)Value ) : (long)( (double)Value ) );
				case TypeCode.Decimal:
					return ( Round ? Math.Round( (decimal)Value ) : (decimal)Value );

				default:
					return null;
			}
		}
		#endregion