.net - Adding 'new' in front of the return type of C# method definition? -


So I recently participated in this C # statement on the job:

  public New string Some functions (Int i) {return base.SomeFunction (i); }  

I searched the web but I think I can get a better answer here.

Now, I feel that it does everything a new string returns from the same value because the call returned by base.SomeFunction (i) ... is this correct?

In addition, is this feature present in other languages ​​(especially Java)?

Edit:
In my specific case, base. Some functions are protected and not virtual Does this make a difference? Thanks

No, that means it hidden some functions If there was no method in the base class with the same signature in the base class instead of you will get a compile-time error (because you will not hide anything there) !)

See for more information. (I do not think this is a duplicate question, because instead of talking about the warning only when it is absent, what is "new".)

Duplicate Example with my answer on that question, To save clickthroughs ...

Here is an example of the difference between concealing a method and overriding it:

  using the system; Class Base {Public Virtual Zero Override Me () {Console.WriteLine ("Base.OverrideMe"); } Public Virtual Zero HideMe () {Console.WriteLine ("Base.HideMe"); }} Category derived: base {public override zero override () {Console.WriteLine ("Derive.OverrideMe"); } Public New Zero HideMe () {Console.WriteLine ("Derived.HideMe"); }} Class Test {Static Zero Main () {Base X = New Deferred (); X.OverrideMe (); X.HideMe (); }}  

Output is:

  generated. Override base. Hydem  

Comments

Popular posts from this blog

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -