Based on: C# Keywords
Keywords are predefined, reserved identifiers that have special meanings to the compiler.
and Based on: Contextual Keywords
A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#.
For Keyword var we have multiple situation for use it, for example:
//One situation for declare a variable:
var a=7;
//Another situation for method hiding in polymorphism subject of OOP:
public new void Foo()
{
//Some Code
}
As you can see var keyword has Several meaning Depending on where it's used, then in my openion var must considered as Contextual Keyword and not keyword!
then, the Definition of Contextual keyword is wrong or considering var as whole keyword is wrong? and why?
Aucun commentaire:
Enregistrer un commentaire