How to call c-tor of base class in C#?

| 2 Comments | No TrackBacks |

Today I was consulted with the above question. In a C# program, we don't have a "MyBase" keyword, however, we have a base keyword. A c-tor is a special case, in C#, the syntax is more like C++.

We should differentiate the case between c-tor and ordinary functions. In a ordinary function, we can just base() to call base function, in a c-tor, we must do this in a different manner:

public CDerived() : base()
{
}

Well this is not quite hard, and it's always easy to get answers from MSDN :-) Personally I'd prefer consulting a e-book rather than a person is already overloaded.

No TrackBacks

TrackBack URL: https://blog.delphij.net/mt/mt-tb.cgi/106

2 Comments

I can't believe that you didn't know this before......

Sure I knew it however that does not mean everybody knows. Frankly this blob is intend to fill the blank so I will have at least one per day :-)

Monthly Archives

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.2.3