Double - IsNaN
Returns a value that indicates whether the specified value is not a number.
public static void Main() { Console.WriteLine("It returns a value indicating whether a value is not-a-number.\n"); Display(32.0, 12); Display(32.0, 0.0); Display(-5, 0.0); Display(0.0, 0.0); } public static void Display(double d1, double d2) { // C# Extension Method: Double - IsNaN bool result = (d1 / d2).IsNaN(); Console.WriteLine("{0}/{1} = {2}", d1, d2, result); }
View Source
using System; public static partial class Extensions { /// <summary> /// Returns a value that indicates whether the specified value is not a number (). /// </summary> /// <param name="d">A double-precision floating-point number.</param> /// <returns>true if evaluates to ; otherwise, false.</returns> public static Boolean IsNaN(this Double d) { return Double.IsNaN(d); } }