예제 #1
0
        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);
        }
    }
예제 #2
0
 /// <summary>
 /// Pattern matching by is operator
 /// </summary>
 /// <param name="student"></param>
 /// <returns></returns>
 public bool IsFullTimeStudent(StudentBase student)
 {
     return(student is FullTimeStudent);
 }