Last post Feb 12, 2016 04:51 AM by PaulTheSmith
Feb 11, 2016 04:03 PM|GoldenRockstar|LINK
How would one check that inheritance is correct and class A is indeed a superclass of B?
Feb 11, 2016 04:36 PM|Mikesdotnetting|LINK
var b = new B();
Console.WriteLine(b.GetType().BaseType == typeof(A)); //should output True
Feb 11, 2016 04:51 PM|PatriceSc|LINK
Or maybe https://msdn.microsoft.com/en-us/library/bewds7kc.aspx and check the "is" and "as" keywords depending on what you want to do.
Feb 12, 2016 04:51 AM|PaulTheSmith|LINK
Whether class A is a superclass of B is a static matter. That is, you determine it by looking at the source code.
Look at the declaration of class B, which class does it inherit from (there can only be one)? If it is not class A then look to see if that class inherits from another. If it is not class A then repeat until there is no more inheritance.
What do you mean by 'inheritance is correct'? Are you questioning the validity of the design that has been chosen? Do you want to know, for example, if 'Rectangle' is a good parent class for 'Square'?