XmlDocument studentData;
        XmlNodeList studentList;
        TotalClass totalClass = null;
        string gender = "";
        studentData = new XmlDocument();
                studentData.LoadXml("<root>"
                    + "<STUDNT ID=\"7\" Gender=\"M\"></STUDNT>"
                    + "<STUDNT ID=\"16\" Gender=\"F\"></STUDNT>"
                    + "<STUDNT ID=\"22\" Gender=\"F\"></STUDNT>"
                    + "<STUDNT ID=\"25\" Gender=\"M\"></STUDNT>"
                    + "<STUDNT ID=\"27\" Gender=\"F\"></STUDNT>"
                    + "<STUDNT ID=\"32\" Gender=\"M\"></STUDNT>"
                    + "<STUDNT ID=\"35\" Gender=\"f\"></STUDNT>"
                    + "<STUDNT ID=\"45\" Gender=\"M\"></STUDNT>"
                    + "<STUDNT ID=\"4423453244\" Gender=\"F\"></STUDNT>"
                    + "<STUDNT ID=\"44344\" Gender=\"F\"></STUDNT>"
                    + "</root>");
        studentList = studentData.SelectNodes("//STUDENT");
        if(studentList != null && studentList.Count > 0)
        {
            foreach(XmlElement student in studentList)
            {
                gender = student.GetAttribute("Gender");
                switch(gender)
                {
                    case "F":
                        totalClass.Females++;   
                        break;
                    default:
                    case "M":
                        totalClass.Males++;                           
                        break;
                }
            }// end loop
        }
        this.lblMales.Text = totalClass.Males.ToString ();      
        this.lblFemale.Text = totalClass.Females.ToString();
        this.lblTotal.Text = (totalClass.Females + totalClass.Males).ToString();
I need some help with this progoram.
I was assigned to debug this program, and I unable to find a way to solve. Keep getting the NullReferenceException when clicked the count button.
 
     
     
    