本文整理汇总了C#中System.Number.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Number.GetType方法的具体用法?C# Number.GetType怎么用?C# Number.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Number
的用法示例。
在下文中一共展示了Number.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mul
public override Number Mul(Number rhs)
{
// java NullPointerException
if(rhs == null) throw new NullReferenceException("rhs is null");
// java getClass()
if(this.GetType() != rhs.GetType())
{
// java ClassCastException
throw new InvalidCastException("rhs has illegal type");
}
Number2 cast = (Number2) rhs;
return new Number2(BigInteger.Multiply(val, cast.val));
}
示例2: Calculate
public static Number Calculate(IBinaryOperandCalculator cal, Number n1, Number n2)
{
if (n1 == null || n2 == null)
{
return 0;
}
switch (n1.TypeCode)
{
case NumberTypeCode.Int32:
return cal.Calculate((int)n1, (int)n2);
case NumberTypeCode.Int64:
return cal.Calculate((long)n1, (long)n2);
case NumberTypeCode.BigInteger:
return cal.Calculate((BigInteger)n1, (BigInteger)n2);
case NumberTypeCode.Double:
case NumberTypeCode.Decimal:
case NumberTypeCode.BigDecimal:
return cal.Calculate((BigDecimal)n1, (BigDecimal)n2);
}
throw new ArgumentException("unsupported add calculate: " + n1.GetType());
}
示例3: CompareTo
public override int CompareTo(Number rhs)
{
// java NullPointerException
if(rhs == null) throw new NullReferenceException("rhs is null");
// java getClass()
if(this.GetType() != rhs.GetType())
{
// java ClassCastException
throw new InvalidCastException("rhs has illegal type");
}
Number2 cast = (Number2) rhs;
return val.CompareTo(cast.val);
}