|
-
Jan 8th, 2010, 12:16 PM
#1
Thread Starter
Lively Member
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.
-
Jan 8th, 2010, 02:58 PM
#2
Addicted Member
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.
Last edited by scottlafoy; Jan 8th, 2010 at 03:06 PM.
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
-
Jan 10th, 2010, 07:50 PM
#3
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|