static void Main(string[] args) { Person p = new BestStudent(); BestStudent bs = p as BestStudent; if (bs != null) { Console.WriteLine("Ok"); } Console.ReadKey(); }
/// <summary> /// Analyse student data. /// </summary> private void PrintStatistics() { Student BestStudent, WorstStudent; int AverageMark = GetStatistics().Item1; GetMinMax(out BestStudent, out WorstStudent); Console.WriteLine($"\n\tThe lowest mark is {BestStudent.Mark} and it belongs to :\n\t{BestStudent.StudentID} {BestStudent.FullName()}"); Console.WriteLine($"\n\tThe highest mark is {WorstStudent.Mark} and it belongs to :\n\t{WorstStudent.StudentID} {WorstStudent.FullName()}"); Console.WriteLine($"\n\tThe medium mark is {AverageMark}"); //pass the avg mark to a student to calculate the grade without creating a convert method BestStudent.Mark = AverageMark; Console.WriteLine($"\n\tThe medium grade is {BestStudent.CalculateGrade()}"); }
static void Main(string[] args) { Console.WriteLine("Hello World!!"); BetterCalculator cal = new BetterCalculator(); var add = cal.Add(10, 20); Console.WriteLine(add); var sub = cal.sub(10, 20); Console.WriteLine(sub); var mul = cal.Add(10, 20); Console.WriteLine(mul); var div = cal.sub(10, 20); Console.WriteLine(div); BestStudent bcal = new BestStudent(); int localSum = bcal.LocalSum(); bcal.BlaBla(); Console.ReadKey(); }