What is the “base class” for C# numeric value types?

后端 未结 6 1641
太阳男子
太阳男子 2020-12-01 11:44

Say I want to have a method that takes any kind of number, is there a base class (or some other concept) that I can use?

As far as I know I have to make overloads f

6条回答
  •  无人及你
    2020-12-01 12:10

    The base class of the numeric types is ValueType.

    Unfortunately that still won't help you: DateTime, bool, Enum and hundreds of other types also derive from ValueType. There's no NumericType base class in .NET.

提交回复
热议问题