Answer: The
IsVirtual property of
MethodBase class gets a value indicating whether the method is virtual.It returns true if this method is virtual; otherwise, false. It is defined as
public bool IsVirtual { get; }
e.g.
typeof(Employee)
.GetProperties()
.Where(p => p.GetAccessors()[0].IsVirtual)
.ToList()
.ForEach(i => Console.WriteLine(i.Name));
Asked In: Many Interviews |
Alert Moderator