what is the easiest way to check if a typeof() is mathematically usable(numeric).
do i need to use the TryParse method or check it by this:
if (!(DC.DataType == typeof(int) || DC.DataType == typeof(double) || DC.DataType == typeof(long) || DC.DataType == typeof(short) || DC.DataType == typeof(float)))
{
MessageBox.Show("Non decimal data cant be calculated");
return;
}
if there is a more easy way to achieve this, your free to suggest
There’s nothing much to do, unfortunately. But from C# 3 onwards, you can do something fancier:
so your original code can be written like this: