The purpose is to enumerate the list and count how many nullable values I have, It will be used in order to test some Linq code because I lack of database. The thing is that no matter how I tried to define it I get from my compiler: "The type or namespace name List
1' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]".
thanks in advance.
Short answer: You can't. A double can only contain a valid double-precision floating point value. Save this answer.
In C# programs, a List reference can be null. This is not the same as it being empty and having zero elements.
double is a primitive type, it cannot be null though. @Meenakshi6246, Double will always give you the value of “0” and we can't assign null value to double or system. DBNull to double.
In C#, you can assign the null value to any reference variable. The null value simply means that the variable does not refer to an object in memory. You can use it like this: Circle c = new Circle(42); Circle copy = null; // Initialized ... if (copy == null) { copy = c; // copy and c refer to the same object ... }
make sure you have:
using System.Collections.Generic;
then it should be as easy as:
List<double?> mylist = new List<double?>();
Are you using mcs? It would be targeting the 1.1 runtime. that would explain "assembly reference not found" Try gmcs for targeting 2.0.
Of course, using System.Collections.Generic;
is the cure for "missing using directive"
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