c# - Access implemented class method -
I want to ask a question about a legacy. I have two classes which were implemented from Absodod
Public category A: Absodod {some method (public void) {}} Public class B: Absodod {Public Zero Certain method () { }} And apply a square public class abodod {public zero dot () {}; Public Zero DoDiff () {}; } When I need to reach class A or B methods then I am getting the error, how can I use
AbsDoc temp = null; If (i.e. =) "a) {temp = new A ();} and {temp = new B ();} temp.SomeMethodA (); // when i < P> temp as you defined it is a AbsDoc . SomeMethodA is not , so you will get a compiler error, it is expected. For example, look at your code again: AbsDoc temp = null; if (absolute == "A") {temp = new A ();} else {temp = new B ();} temp.SomeMethodA (); // when I if ultimate! = "A" ? Will be your temp , then instead of B one a and this You can not call SomeMethodA if you want to call SomeMethodA , then you will need to enter temp : A) Temp = New A (); (A) Temp.) Some hypotia ();} and {temp = new (b) Some method ();} By your comment, it looks like you do something like this:
< Code> AbsDoc temp = null; If (param == "A") {var a = new A (); A.SomeMethodA (); Temporary = A; } And {var b = new b (); v.SomeMethod (); Temp = b; } Temp.DoIt (); In this way you do not need to do two base class contents twice.
Comments
Post a Comment