Hi,
I have seen some code recently that had the following method
signatures:
private new void Push(object o)
And
public new objectname FunctionName()
So my question is what is happening here? With the first one why would
new be with a void return type? With the second one I am assuming that
the function would return a new object of that type, correct?
JJ
Nicholas Paldino [.NET/C# MVP] - 21 Dec 2005 23:50 GMT
JJ,
In this case, the new is not related to the return type of the method.
Rather, new is used to indicate that the method shadows a method with the
same signature declared on the base class.
Hope this helps.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi,
>
[quoted text clipped - 12 lines]
>
> JJ
jjmraz@hotmail.com - 22 Dec 2005 12:01 GMT
Ah it says use me instead of the one in the base call when called upon?
JJ
Jon Skeet [C# MVP] - 22 Dec 2005 12:25 GMT
> Ah it says use me instead of the one in the base call when called upon?
Not quite. It says "this is actually a different method which happens
to have the same name, it's not trying to override another method".
See http://www.pobox.com/~skeet/csharp/faq/#override.new

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mattias Sjögren - 21 Dec 2005 23:52 GMT
>So my question is what is happening here?
The new modifier makes it explicit that you want your method to not
override a virtual method with the same name and signature in a base
class, but rather hide it. See
http://msdn.microsoft.com/library/en-us/csref/html/vclrfnewoppg.asp
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.