Results 1 to 3 of 3

Thread: Basic Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    103

    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.

  2. #2
    Addicted Member scottlafoy's Avatar
    Join Date
    Feb 2009
    Location
    Calgary Alberta, Canada
    Posts
    148

    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

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width