private static void addStudent() { while (true) { Console.WriteLine("nhap roolnumber: "); string roolNumber = Console.ReadLine(); Console.WriteLine("nhap name: "); string name = Console.ReadLine(); Console.WriteLine("nhap email: "); string email = Console.ReadLine(); Console.WriteLine("nhap phone: "); string phone = Console.ReadLine(); Student student = new Student(roolNumber, name, email, phone); list.Add(student); Console.WriteLine(student.ToString()); Console.WriteLine("Hello World!"); Console.WriteLine("ban co muon nhap tiep khong(y/n)"); string answers = Console.ReadLine(); if (answers.Equals("k")) { break; } } }
static void Main(string[] args) { Student Tania = new Student(); Console.WriteLine(Tania.ToString()); Console.WriteLine(Tania[Education.Bachelor]); Console.WriteLine(Tania[Education.Master]); Console.WriteLine(Tania[Education.SecondEducation]); Person ob = new Person("Tania", "Lunyk", new DateTime(1999, 09, 24)); Tania = new Student(ob, Education.Bachelor, 311); // Console.WriteLine(Tania.ToString()); Exam ob1 = new Exam("Math", 5, new DateTime(2018, 12, 16)); Exam[] ob2 = new Exam[] { ob1 }; Tania.AddExams(ob2); Console.WriteLine(Tania.ToString()); int column = 100; int row = 100; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); String[] exams1 = new string[column * row]; for (int i = 0; i < column * row; i++) { exams1[i] = ob1.ToString(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); Console.WriteLine("RunTime1 " + elapsedTime); Stopwatch stopWatch2 = new Stopwatch(); stopWatch2.Start(); String[,] exams2 = new string[column, row]; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { exams2[i, j] = ob1.ToString(); } } stopWatch2.Stop(); TimeSpan ts2 = stopWatch2.Elapsed; // Format and display the TimeSpan value. string elapsedTime2 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts2.Hours, ts2.Minutes, ts2.Seconds, ts2.Milliseconds); Console.WriteLine("RunTime2 " + elapsedTime2); Stopwatch stopWatch3 = new Stopwatch(); stopWatch3.Start(); String[][] exams3 = new string[row][]; for (int i = 0; i < row; i++) { exams3[i] = new string[column]; for (int j = 0; j < column; j++) { exams3[i][j] = ob.ToString(); } } stopWatch2.Stop(); TimeSpan ts3 = stopWatch3.Elapsed; // Format and display the TimeSpan value. string elapsedTime3 = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts3.Hours, ts3.Minutes, ts3.Seconds, ts3.Milliseconds); Console.WriteLine("RunTime2 " + elapsedTime3); /*string str, str1; * str = Console.ReadLine(); * int a; * int.TryParse(str, out a); * str1 = Console.ReadLine(); * int b = int.Parse(str1); * Console.WriteLine(a+b);*/ }
static void Main(string[] args) { Person p = new Person() { ID = 7, Name = "avi" }; Console.WriteLine(p.ToString()); Console.WriteLine(p); Console.WriteLine(); Student s = new Student() { ID = 8, Name = "benny", Grade = 99, StudentNumber = 123 }; Console.WriteLine(s); // reference is Object.ToString() //public void Console.WriteLine(object o) //{ // o.ToString() --> console //} Console.WriteLine(s.ToString()); // reference is Student Console.WriteLine(Add(2, 3)); //Console.WriteLine(2+3); Console.WriteLine(p.GetHashCode()); Console.WriteLine(s.GetHashCode()); Person p2 = p; Console.WriteLine(p2.GetHashCode() == p.GetHashCode()); Person p3 = new Person() { ID = 7 }; Console.WriteLine(p.Equals(p3));//True Console.WriteLine(p.GetType().Name); Console.WriteLine(s.GetType()); Car c = new Car() { LicensePlate = 7 }; Console.WriteLine(p.Equals(c)); Console.WriteLine(); Type t1 = p.GetType(); Type t2 = typeof(Person); Console.WriteLine(t1.Name); Console.WriteLine(t1.IsClass); Console.WriteLine(t1.IsPublic); Console.WriteLine(t1.Namespace); foreach (var perMethods in t1.GetMethods()) { Console.WriteLine(perMethods); } Console.WriteLine(); foreach (var perMembers in t1.GetMembers()) { Console.WriteLine(perMembers); } }
public static void Main(string[] args) { Student jojo = new Student(1, "jojo"); Console.Write(jojo.ToString()); }
public void PrintBasicInfo(Student student) { Console.WriteLine(student.ToString()); }