public DerivedClass(string x) : base(x)
{
x="blah";
}
will this code call the base constructor with a value of x as “blah”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The base call is always done first, but you can make it call a static method. For example:
Now if you call
then the base constructor will be called with “Hello Foo!”.
Note that you cannot call instance methods on the instance being constructed, as it’s not “ready” yet.