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:
(如果我从Exception类继承,我想做这样的事情:)
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.
(基本上,我想要的是能够将字符串消息传递给基本Exception类。)
ask by lomaxx translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…