In my application i have a method that takes three numbers as arguments. However, the method shall only be able to take numeric values as arguments, and therefore I need to check wether the arguments are numeric or not. How can I do this in an easy and preferably elegant way? Thanks is advance
public Triangle(double a, double b, double c) {
if ((a != ?) || (b != ?) || (c != ?)){
throw new ArgumentException("Not a number")
}
sides = new double[] { a, b, c };
}
C# is strongly typed. Therefore, if you specify that your parameters are numeric, you won’t be able to call your method with non-numeric parameters.