-
Basic Question
Hi,
I'm quite new to c#, if possible could someone explain what the need for the following is please/
1. An abstract class / or interface allows a user inherit the methods etc in a new class, and this is where the functionality for methods etc is added (NO instantiation).
2. A regular class (e.g. Public), allows a user to add functionality directly to the methods of this class. This class is then instantiated in another class and the methods can be accessed. E.g. Class1 Class2 = new Class1;
Class2.MethodCall();
What I do not understand is:
What is the neeed to instantiate classes, why cant classes just be abstract and then there is no need for them to be instantiated every time you want to use their methods?
Please can someone explain why they both exist and maybe a scenario that explains this.
Thanks all.
-
Re: Basic Question
you would want to create an intstance of a class if you were using it to store proportys. that way you could have the same class being used by multiple times, once per instance.
-
Re: Basic Question
Consider a form that you use to edit a record. You might have multiple TextBoxes on the form, right? How can you have multiple TextBoxes on a form if you cannot create instances of the TextBox class?