Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Make a overloaded constructor of a class with mandatory implementation in the inherited class in c#

Class A with constructor A(string A1, string A2)


Class B inherits class A

In this inheriting class I want to mandate the implementation of the base constructor A(string A1, string A2)

If this is not used in the inheriting class compilation error should come for class B.


Thanks in advance for the help

Thanks
Venkat
Posted
Updated 13-Apr-10 4:47am
v3

You can't mandate it like you can with a method overload, as constructors are not inherited. Equally, if you try and compile new B ("Foo", "Bar") against your example above, you'll get a compile error, so in most circumstances (e.g. non-reflective and non dynamic (in the C# 4 sense) code this shouldn't be a problem.
 
Share this answer
 
Constructors can't be abstract





;P
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900