What is the purpose of ISVirtual property in C# Reflection?

 Posted by Rajnilari2015 on 9/22/2015 | Category: C# Interview questions | Views: 212 | Points: 40
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 

Comments or Responses

Login to post response