I thought the keyword "new" in C# was only use to instantiate a class. Lately I discovered it can also hide inheritance. So are there any cases where you would use it?
Asked
Active
Viewed 124 times
-1
-
Is the question about get all usages of `new` within VS or when to use `new` to hide an inherited member? In the latter case this is a diplucate of http://stackoverflow.com/questions/6576206/what-is-the-difference-between-the-override-and-new-keywords-in-c – MakePeaceGreatAgain Jan 08 '16 at 08:46
-
What part of the documentation is unclear?.. – Sayse Jan 08 '16 at 08:47
-
Possible duplicate of [Why would you want to hide a method using \`new\`?](http://stackoverflow.com/questions/7184294/why-would-you-want-to-hide-a-method-using-new) – Wai Ha Lee Jan 08 '16 at 08:48
-
The question is to list all usages of keyword "new" in a topic. MSDN documentation already answer this question though. – V.Leymarie Jan 08 '16 at 08:50
2 Answers
5
You can look at the MSDN:
In C#, the new keyword can be used as an operator, a modifier, or a constraint.
Used to create objects and invoke constructors.
Used to hide an inherited member from a base class member.
Used to restrict types that might be used as arguments for a type parameter in a generic declaration.

Rahul Tripathi
- 168,305
- 31
- 280
- 331
4
In C#, the new keyword can be used as an operator, a modifier, or a constraint.
new Operator: Used to create objects and invoke constructors.
new Modifier: Used to hide an inherited member from a base class member.
new Constraint: Used to restrict types that might be used as arguments for a type parameter in a generic declaration.
Source: MSDN

Martino Bordin
- 1,412
- 1
- 14
- 29
-
2Please reference the [source](https://msdn.microsoft.com/en-us/library/51y09td4.aspx). – Mike Eason Jan 08 '16 at 08:47
-
I think @MikeEason means you should reference the page you copy/pasted your answer from. See [this answer](http://stackoverflow.com/a/34672801/1364007) for what would be better: (a) a link to the original page, (b) quote formatting (yellow background) so it's clear they didn't write it. – Wai Ha Lee Jan 08 '16 at 09:01
-