tags:

views:

151

answers:

4

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 List1' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]".

thanks in advance.

+6  A: 

make sure you have:

using System.Collections.Generic;

then it should be as easy as:

List<double?> mylist = new List<double?>();
John Boker
This is excactly what I tried first still getting the error
Chris
List<> is in System.Collections.Generic, as the changed answer states :)
Jimmy
@jimmy, i was adding it as you were putting in this comment, @chris, what @jimmy said.
John Boker
+2  A: 

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"

Jimmy
A: 

List<double?> l = new List<double?>();

Works for me... List(Of T) as is Nullable(Of T) is in System.Core do you have that referenced?

David
A: 

With John Boker's answer, you could do something like the following:

List<double?> mylist = new List<double?>();
int nullItemsCount = mylist.Count(item => !item.HasValue);
Chris Conway