Problem in Interfaces (polymorphism) C# -


I have two classes, which have some common methods like funcA (), funcB ()

And in some ways it only relates to its class ...

I have created the interface of the test interface

  Public Interface Test Interface {void funcA () void funcB () } Public Class Class A: Test Interface {Public Zero Funny () {console. Weedline ("This is Class A Funca"); } Public Zero FuncB () {Console.WriteLine ("This is Class A FuncB ()"); } Public Zune myFuncA () {Console.WriteLine ("This is my own function"); }} Public Class Classb: Test Interface {Public Zero (funcA) {Console.WriteLine ("This is Class B Funca"); } Public Zero (funcB) {Console.WriteLine ("This is Class B FuncB ()"); } Public zero myFuncB () {Console.WriteLine ("This is my own function B"); }} Public static zero major () {test interface test = new class (); Test.funcA (); }  

As you see in the above two sections. I have two functions that are not part of the myFuncA () and myFuncB () interface. They are related only to their own class.

How do I tell them the main method? Where I am creating the object of the test interface and starting it with some child classes.


Actually I have different classes in DAL.

They have some common methods and some methods related to their own class.

I want to apply the factory pattern to this.

What should I do now?

If you are asking what you can do something like this:

 <0> public static zero main (string [] a) {Test Interface Test = new class (); Test.myFuncA (); }  

The answer is not the first time you have to put it in the class. The fact is that you think that you need to do this indicates that something in your design is probably wrong.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -