Why do I get the error object reference not set to instance of an ojbect while adding an object to a list in c# wpf? : <p>I have a C# WPF application with a form in it.  The form is supposed to take two values(firstName and lastName) and then use the Instructor class to add it to my listview element. On the line <code>instList.Add(new Instructor...</code> I am getting the error <code>object reference not set to instance of an object</code>.  Why does this happen?</p>

<p>This is my mainwindow.xaml.cs:</p>

<pre><code>namespace AssignmentTwoPartTwo
{
    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window
    {
        public List&lt;Instructor&gt; instList;
        public MainWindow()
        {
            InitializeComponent();
            List&lt;Instructor&gt; instList = new List&lt;Instructor&gt; { };
            lvInstructorList.ItemsSource = instList;
        }

        private void btnCreateInstructor_Click(object sender, RoutedEventArgs e)
        {
            spCreateInstructor.Visibility = (spCreateInstructor.Visibility == Visibility.Hidden) ? Visibility.Visible : Visibility.Hidden;
        }

        private void btnInstructorSubmit_Click(object sender, RoutedEventArgs e)
        {
            instList.Add(new Instructor() { firstName = txtInstructorFirstName.Text, lastName = txtInstructorLastName.Text });
            lvInstructorList.ItemsSource = instList;
        }
    }
}
</code></pre>

<p>This is Instructor.cs</p>

<pre><code>namespace AssignmentTwoPartTwo
{
    public class Instructor
    {
        public string firstName { set; get; }
        public string lastName { set; get; }
    }
}
</code></pre>
