Results 1 to 4 of 4

Thread: Are constructors in Csharp inherited?

  1. #1
    Join Date
    Nov 2009
    Posts
    63

    Are constructors in Csharp inherited?

    I am new Csharp learner. I am not that good at programming. Already I am confused with alot of things in Csharp in the beginning. Now I have been given a question that whether Constructors in Csharp can be inherited? I am not able to find the right answer for this ? Is it possible to Inherit Csharp contructors? If yes, then how?

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Are constructors in Csharp inherited?

    I was also confused that if a class can be inherited then is it possible that constructors also can be inherited in Csharp? The answer is No, constructors in Csharp cannot be inheritted at all. Although a child class can inhabit many of the parent class properties, but that does not states that the parent class construtor's argument list is also same with the child class constructor argument list thus allowing constructor to be inherited. Simple as that.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Are constructors in Csharp inherited?

    NO. Lets assume that if a class was capable of inheriting its base class constructor what will happen. Simply all the classes would contain constructors without any argument list. And that is illegal in C sharp. So hence to keep it simple C sharp does not at all allows constructors to be inheritted in anyway.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Are constructors in Csharp inherited?

    There is now way or any method using which constructors in C# can be inherited. For intance if inheritance of C# was legal in C#, then initalization within a parent class constructor which is a must can be easily terminated. But what will happen in case a new version of that parent class is generated with its new constructor. This will result in an auntomatic generation of new constructor in your parent class. That can create a huge chaos.

Similar Threads

  1. SBS 2003 server has had inherited permissions removed
    By Grahamb in forum Active Directory
    Replies: 1
    Last Post: 22-09-2012, 11:33 AM
  2. Constructors in Java help
    By cloud101 in forum Software Development
    Replies: 4
    Last Post: 18-01-2012, 05:02 PM
  3. what are constructors in C++?
    By Asis in forum Software Development
    Replies: 4
    Last Post: 29-12-2010, 08:38 AM
  4. Class Inherited From system.windows.shapes.polygon
    By Amaresh in forum Software Development
    Replies: 4
    Last Post: 05-02-2010, 10:54 PM
  5. Replies: 2
    Last Post: 30-07-2009, 05:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,278,415.82274 seconds with 16 queries