.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: No, that means it hidden 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: Output is:
In my specific case, base. Some functions are protected and not virtual Does this make a difference? Thanks 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) !)
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 (); }}
generated. Override base. Hydem
Comments
Post a Comment