vendredi 15 mai 2015

Why cast from MemberInfo to MethodInfo is allowed?

Documentation for System.Reflection.MemberInfo has the following example:

foreach (MemberInfo mi in t.GetMembers())  
{
    if (mi.MemberType == MemberTypes.Method)
    {
        foreach (ParameterInfo pi in ((MethodInfo)mi).GetParameters())

Notice the cast (MethodInfo)mi). MemberInfo and MemberInfo don't have a common parent, so why cast is allowed ?





Aucun commentaire:

Enregistrer un commentaire