Results 1 to 4 of 4

Thread: inheritence in c#

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Answers
    7

    inheritence in c#

    what is
    1.virtual
    2.override
    3.sealed override
    4.new........


  2. #2
    Junior Member
    Join Date
    Nov 2007
    Answers
    24

    Re: inheritence in c#

    All these keywords are used with Methods in class.

    1.Virtual: - if you use these keyword with method, the method may be overridden in derived class, not compulsory.
    class MyClass
    {
    public virtual void MyMethod()
    {..........}
    }

    2.Override: - To override a method in derived class this keyword is used. To use this keyword in derived class the method in base class must be declared either with virtual or abstract.

    class MyClass
    {
    public virtual void MyMethod()
    {..........}
    }
    class childClass:MyClass
    {
    public override void MyMethod()
    {..........}
    }


    3.Sealed Override: - This keyword must be used with a method in derived class only, to avoid overriding in further derived class of this class.To use this keyword in derived class the method in base class must be declared either with override or abstract.if you use this keyword the method can't overriden in further derived class.

    class MyClass
    {
    public virtual void MyMethod()
    {..........}
    }
    class childClass:MyClass
    {
    public sealed override void MyMethod()
    {..........}
    }
    next if you derive class from this MyClass you can't override MyMethod

    4.New - this keyword can be used with any methods to write new definition in derived class, to hide base class methods that is not declared with the keyword virtual or abstract.

    class MyClass
    {
    public void MyMethod()
    {..........}
    }
    class childClass:MyClass
    {
    public new void MyMethod()
    {..........}
    }

    Last edited by shilpa.c; 08-25-2009 at 03:06 AM.

  3. #3
    Banned
    Join Date
    Oct 2009
    Answers
    6

    Re: inheritence in c#

    still i cant understand......make it more simpilar and give some examples please


  4. #4

    Re: inheritence in c#

    sfdffdfdfdff
    dfdfs



  5.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact