Possible Duplicate:
C# newbie: what’s the difference between “bool” and “bool?” ?
Hi, While reading the code of the NUnit project's assert class, I came across this particular construct -
public static void AreEqual(double expected, double? actual, double delta)
{
AssertDoublesAreEqual(expected, (double)actual, delta ,null, null);
}
In this function the second input parameter is entered as double?
.
The interesting thing is that this code compiles without issue in VS2010 (C# 4.0).
Anyone know why this is NOT throwing an error ? Why is double?
considered a valid keyword and is there any special significance to the ?
.
Updated on April 27, 2019. The double is a fundamental data type built into the compiler and used to define numeric variables holding numbers with decimal points. C, C++, C# and many other programming languages recognize the double as a type. A double type can represent fractional as well as whole values.
This data type is widely used by programmers and is used to store floating-point numbers. All real numbers are floating-point values. A variable can be declared as double by adding the double keyword as a prefix to it. You majorly used this data type where the decimal digits are 14 or 15 digits.
Keywords double and float are used for declaring floating type variables. For example: float number; double longNumber; Here, number is a single-precision floating type variable whereas, longNumber is a double-precision floating type variable.
Double programming is widely accepted as the gold standard of program validation and quality. In double programming, two programmers work independently from the same specifications. When they are done, they compare output, which may be a dataset, listing, table, or graph.
double?
is just shorthand for Nullable<double>
; basically, a double
that can be null
. But the code is not very safe. If actual
is null
, (double)actual
will throw an exception.
It's a nullable type. So it's a double that can also be null.
See here for more info.
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