0
 public List<string> myitems { get; set; }
    //Store All unique ID of this date in a list
    public void myitem(string Index)
    {
        myitems.Add(Index);
    }

  if (temp.Start == received)
            {

                scheduledItem scheduleditem = new scheduledItem(temp.Name, "1pm", "true");
                DataCollection.Add(scheduleditem);
                myitem(temp.UniqueID.ToString()); 
            }
            else
            {
                MessageBox.Show("Nothing");

            }

Any idea what went wrong with myitems.add(index); ?

1
  • 1
    Where is the new List<string>? It would explain the null ("lack of object").. Commented Jun 24, 2012 at 5:49

2 Answers 2

3

You have to instantiate/initialize the List<T>.

 private List<string> _list = new List<string>();

 public List<string> myitems 
 { 
     get { return _list; }
 }
Sign up to request clarification or add additional context in comments.

Comments

2

You haven't actually initialized myitems. You need add this line of code somewhere, such as the constructor of your class

myitems = new List<string>();

1 Comment

OH! Okay , i'm starting to get the meaning of Initialize Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.