When we do something like double.IsNaN
-- what exactly is happening?
If double
was a class I would understand it, but double is a struct and it is a value type so how does C# actually call a static method on a value type?
Java Double isNaN() MethodThe isNaN() method of Java Double class returns true: If the value of this Object is Not-a-Number (NaN). If the argument passed is Not-a-Number (NaN). Otherwise, the method returns false.
To check whether a floating point or double number is NaN (Not a Number) in C++, we can use the isnan() function. The isnan() function is present into the cmath library. This function is introduced in C++ version 11.
In C#, the Double. NaN field represents a value that is not a number. It is constant.
A method or operator returns NaN when the result of an operation is undefined. For example, the result of dividing zero by zero is NaN, as the following example shows. (But note that dividing a non-zero number by zero returns either PositiveInfinity or NegativeInfinity, depending on the sign of the divisor.) C# Copy.
Structs can have methods.
...
Just incase an example is required:
struct Foo {
public void Hey ()
{
Console.WriteLine("hey");
}
public static void DoSomething ()
{
Console.Read();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With