1

The input generic type could be a int, double, long, short, unsigned, etc. and they all represent numeric values.

Besides checking if the type equals to each individual type:

(typeof(T) == typeof(int)) || (typof(T) == typeof(double)) ...

is it any way to simplify this or-cluster?

EDIT:

I am aware of the other threads that provide solutions to check types, but they are mostly using switch-cluster or or-cluster, which is very similar to my solution above in the way that we still need to go over each individual type. I am looking for a more agile solution that avoids going into each types. This may be impossible but I think this would be a pretty handy thing to provide in generic class.

jamesdeath123
  • 4,268
  • 11
  • 52
  • 93
  • Please see the question here: http://stackoverflow.com/questions/124411/using-net-how-can-i-determine-if-a-type-is-a-numeric-valuetype – goric Feb 05 '14 at 16:05
  • @goric I've read those questions before asking the post, but the answer uses switch, which essentially does the same thing with the or-cluster or if-elseif-cluster. I am looking for a more agile solution that can be finished in a few lines. It is okay if there is no simpler way to do it though. – jamesdeath123 Feb 05 '14 at 16:16

0 Answers0