Tech
Forums
Jobs
Books
Events
Live
Interviews Prep
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Object reference not set to an instance of an object.
ankit r
Apr 13 2012 12:55 PM
1.8k
Reply
Hello everyone and thanks in advance.
I am getting an error " Object reference not set to an instance of an object." when I try to add an item to a integer list of class "FreeHoursClass" which has a public list "FreeHoursList".
This is my code.
public class FreeHoursClass
{
public List<int> FreeHoursList = new List<int>();
}
private void button1_Click(object sender, EventArgs e)
{
FreeHoursClass[] ff = new FreeHoursClass[30];
ff[5].FreeHoursList.Add(9);
MessageBox.Show(ff[5].FreeHoursList[0].ToString());
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Save a List of objects in another object.
Dataset - assingnment of value to cell without effect