D
Daniel Billingsley
Given
classA {}
Type typeA = typeof(ClassA);
1) isn't
checkType.IsSubclassOf(typeA)
going to always give the same results as
typeInheritsFrom(checkType, typeA)
given
bool typeInheritsFrom(Type typeToCheck, Type checkAgainst)
{
Type baseType = typeToCheck;
while (baseType != null)
{
if(baseType == checkAgainst)
return true;
baseType = baseType.BaseType;
}
}
2) Wouldn't
if (baseType is checkAgainst)
be a little clearer in C# than
if (baseType == checkAgainst)
even though I think it would work out to the same result.
classA {}
Type typeA = typeof(ClassA);
1) isn't
checkType.IsSubclassOf(typeA)
going to always give the same results as
typeInheritsFrom(checkType, typeA)
given
bool typeInheritsFrom(Type typeToCheck, Type checkAgainst)
{
Type baseType = typeToCheck;
while (baseType != null)
{
if(baseType == checkAgainst)
return true;
baseType = baseType.BaseType;
}
}
2) Wouldn't
if (baseType is checkAgainst)
be a little clearer in C# than
if (baseType == checkAgainst)
even though I think it would work out to the same result.