public int CalculateBonusPoint(StudentBase student) { int bonusPoint = student switch { StudentBase std when std is FullTimeStudent => 200, StudentBase std when std is PartTimeStudent => 100, _ => 0 }; return(bonusPoint); } }
/// <summary> /// Pattern matching by is operator /// </summary> /// <param name="student"></param> /// <returns></returns> public bool IsFullTimeStudent(StudentBase student) { return(student is FullTimeStudent); }