When creating a derived class in C#, is it possible to overwrite a 0 parameter virtual function with an n parameter function?

You're not actually overriding the method, you're simply defining a new overload To be able to override a method, the base method must be declared a public (or protected ) virtual (or abstract ) method and your derived class must use the same exact signature In your case, no overridable method with that signature exists in the base class so it is not allowed. It would be allowed if an overridable method existed with the signature Init(int) but there isn't, the compiler would yield an error here.

You're not actually overriding the method, you're simply defining a new overload. To be able to override a method, the base method must be declared a public (or protected) virtual (or abstract) method and your derived class must use the same exact signature. In your case, no overridable method with that signature exists in the base class so it is not allowed.It would be allowed if an overridable method existed with the signature Init(int) but there isn't, the compiler would yield an error here.

This is actually what I figured. Guess that means I'll just leave it up to the derived classes to have their own Init functions. Thanks.

– Shawn Sep 21 at 4:19.

This is not possible. What would the parameter be if it's called from the base class?

An override needs to have the same signature, otherwise there is no point in making it virtual.

Public override void Init(int multiplier) { } This is not an override. Since you are introducing new multiplier it would be considered new method. However if you do this.

Public override void Init(){} It will be override. However if you do this in derived class it will be considered overload. Public void Init(int Multiplier) {}.

The compiler will give you an error, because "there is nothing to override". Basically, the overridden method must match the underlying signature: msdn.microsoft.com/en-us/library/ms17315....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions