Const vs new const

No matter what I google, there is no answer for that! In a C # class, what does the new keyword do for the const field?

eg:

private const int ConstOne = 0;
private new const int ConstTwo = 0;
+5
source share
2 answers

The keyword is newused when hiding an element from the base class.
It actually does nothing; it simply tells the compiler not to warn you that you are hiding the base field.

See documentation

+9
source

The new keyword is used when hiding a member. It works for all members of a class, such as methods, fields, etc.

, , , , , , , .

Google . : http://www.akadia.com/services/dotnet_polymorphism.html

+3

All Articles