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?!? } }
I use the following:
MyClass test = new MyClass(); test.SetValue();