C# Programming/Keywords/new
Appearance
The new
keyword has two different meanings:
- It is an operator that requests a new instance of the class identified by its argument.
- It is a modifier that explicitly hides a member.
As an example, see the code below:
public class Car
{
public void go()
{
}
}
Car theCar = new Car(); // The new operator creates a Car instance
int i = new int(); // Identical to … = 0;
public class Lamborghini : Car
{
public new void go() // Hides Car.go() with this method
{
}
}
C# Keywords | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Special C# Identifiers (Contextual Keywords) | |||||||||||||||
| |||||||||||||||
Contextual Keywords (Used in Queries) | |||||||||||||||
|