public MainForm() { InitializeComponent(); _list = new StudentList(); _sortMode = SortMode.Surname; var columns = new List <string>() { "ID", "Name", "Surname", "Subject Name", "Subject Mark" }; AddColumns(ref columns); }
private void DeserializeButton_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog(); dialog.Filter = "Binary files|*.bin"; if (dialog.ShowDialog() == DialogResult.OK) { switch (dialog.FilterIndex) { case 1: var bin = new BinaryFormatter(); using (var file = new FileStream(dialog.FileName, FileMode.Open, FileAccess.Read)) { _list.Clear(); _list = (StudentList)bin.Deserialize(file); } break; } } }
static void Main(string[] args) { var list = new StudentList(); list.Add(new Student { Id = 1, Name = "Nikolay", Surname = "Gogol", GPA = 2.50 }); list.Add(new Student { Id = 2, Name = "Fyodor", Surname = "Dostoevsky", GPA = 3.48 }); list.Add(new Student { Id = 3, Name = "Leo", Surname = "Tolstoy", GPA = 3.45 }); list.Add(new Student { Id = 4, Name = "Alexander", Surname = "Pushkin", GPA = 3.71 }); list.Add(new Student { Id = 4, Name = "Ernest", Surname = "Hemingway", GPA = 3.11 }); var highestGpas = list.GetStudentWithHighestGPA(); highestGpas.ForEach(s => Console.WriteLine($"Soyad: {s.Surname} ve GPA: {s.GPA}")); var results = list.GetStudentByName("Fyodor"); results.ForEach(s => Console.WriteLine($"{s.Surname}")); list.RemoveBySurname("Hemingway"); list.Yazdır(); var getIdByUser = list.GetStudentById(4); Console.WriteLine(getIdByUser.Name + getIdByUser.Surname); Console.ReadLine(); }