private new void

  • Thread starter Thread starter jjmraz
  • Start date Start date
J

jjmraz

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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top