0

Hi,
i have error in line: "student.Add(info);"
Error 1 Use of unassigned local variable 'info'

public struct Students
        {
            public string Name;
            public int ID;
            public string Date;
        };

        static void Main(string[] args)
        {

            ArrayList student = new ArrayList();

            Students info;

            info.Name = "Marko";
            info.ID = 12;

            student.Add(info);

            foreach (Students show in student)
            {
                Console.WriteLine("Name:{0}, ID:{1}", show.Name, Convert.ToString(show.ID));
            }
}
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Lolalola
1

Modify your Students declaration to match the following:

Students info = new Students();
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.