|
-
January 29th, 2010, 10:25 AM
#1
scope of List<Queue> different?
I commented the following: Look at the 'THIS FAILS, WHY?' line at SetValue(), why does it fail? The error message is that the object is null (NullReferenceException), however the constructor is correct isn't it? I tested it with the someInteger variable, and everything is ok there...
Thanks for any reply!
public class MyClass
{
private List<Queue> listOfItems;
private int someInteger;
public MyClass()
{
List<Queue> listOfItems = new List<Queue>();
listOfItems.Add(new Queue()); // THIS WORKS
someInteger = 0; // THIS WORKS
}
public void SetValue()
{
someInteger = 1; // THIS WORKS
listOfItems.Add(new Queue()); // THIS FAILS, WHY?!?
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|