-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.cs
39 lines (37 loc) · 1.11 KB
/
Student.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
public class Student
{
public string StudentName {get; set;}
public string StudentID {get; set;}
private static int nextID = 1;
public string Program {get; set;}
public static List<Student> students = new List<Student>();
public List<Course> Courses {get;set;} = new List<Course>();
public Student()
{
}
public static void AddStudent()
{
var student = new Student();
Console.WriteLine("Input Student Name");
student.StudentName = Console.ReadLine();
Console.WriteLine("Input your Program in the School");
student.Program = Console.ReadLine();
student.StudentID = nextID++.ToString();
students.Add(student);
Console.WriteLine("Student Successfully Created");
}
public static void ViewAllStudent()
{
if (students == null)
{
Console.WriteLine("No students available.");
return;
}
foreach (var item in students)
{
Console.WriteLine($"Student ID: {item.StudentID}, Student Name : {item.StudentName}");
}
}
}