Possible Duplicate:
Detect if a method was overridden using Reflection (C#)
Is there a way to tell if a method is an override? For e.g.
public class Foo
{
public virtual void DoSomething() {}
public virtual int GimmeIntPleez() { return 0; }
}
public class BabyFoo: Foo
{
public override int GimmeIntPleez() { return -1; }
}
Is it possible to reflect on BabyFoo and tell if GimmeIntPleez is an override?
You can use MethodInfo.DeclaringType to determine if the method is an override (assuming that it’s also
IsVirtual = true).From the documentation:
Here’s an example: