0% found this document useful (0 votes)
5 views2 pages

Menu-Driven Application - Student Details

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Menu-Driven Application - Student Details

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;

namespace MenuDrivenApp
{
class Student
{
public string Name { get; set; }
public int Age { get; set; }
public string Grade { get; set; }

public override string ToString()


{
return $"Name: {Name}, Age: {Age}, Grade: {Grade}";
}
}

class Program
{
static List<Student> students = new List<Student>();

static void Main(string[] args)


{
while (true)
{
Console.WriteLine("Menu: 1. Add, 2. Display, 3. Exit");
string choice = Console.ReadLine();
switch (choice)
{
case "1":
AddStudent();
break;
case "2":
DisplayStudents();
break;
case "3":
return;
default:
Console.WriteLine("Invalid choice.");
break;
}
}
}

static void AddStudent()


{
Student s = new Student();
Console.WriteLine("Enter Name: ");
s.Name = Console.ReadLine();
Console.WriteLine("Enter Age: ");
s.Age = int.Parse(Console.ReadLine());
Console.WriteLine("Enter Grade: ");
s.Grade = Console.ReadLine();
students.Add(s);
}

static void DisplayStudents()


{
foreach (var student in students)
{
Console.WriteLine(student);
}
}
}
}

You might also like