Skip to main content
Question Protected by miken32
deleted 3 characters in body
Source Link
John Smith
  • 7.4k
  • 7
  • 52
  • 63

If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?

For example,

If if I inherit from the Exception class I want to do something like this:

class MyExceptionClass : Exception { public MyExceptionClass(string message, string extraInfo) { //This is where it's all falling apart base(message); } } 

Basically what I want is to be able to pass the string message to the base Exception class.

If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?

For example,

If I inherit from the Exception class I want to do something like this:

class MyExceptionClass : Exception { public MyExceptionClass(string message, string extraInfo) { //This is where it's all falling apart base(message); } } 

Basically what I want is to be able to pass the string message to the base Exception class.

If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?

For example, if I inherit from the Exception class I want to do something like this:

class MyExceptionClass : Exception { public MyExceptionClass(string message, string extraInfo) { //This is where it's all falling apart base(message); } } 

Basically what I want is to be able to pass the string message to the base Exception class.

Copy edited (e.g. ref. <http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29>).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
deleted 2 characters in body; edited tags
Source Link
JoshJordan
  • 13k
  • 10
  • 55
  • 65
Loading
Source Link
lomaxx
  • 116.2k
  • 58
  • 148
  • 181
Loading