Important conditions for using the VAR keyword:
<1> can only be used for local variables and cannot be used for fields.
<2> can only be used when initialization is included in a variable declaration.
<3> once the compiler infers the type, it is fixed and cannot be changed (this does not know what it means).
Access modifiers:
<1>private: The default access level
<2>public
<3>protected
<4>internal
<5>protected Internal
Local constant: Local variable once it is initialized, its value cannot be changed, just as local variables, local constants must be declared inside the block. The two most important characteristics of a constant are the following (the thing that writes this constant is because in writing a C # program, I have never defined a constant, and now I'm going back to rewriting learning C # Basics):
<1> constants must be initialized in the declaration.
<2> constants cannot be changed after they have been declared.
The core declarations for constants are as follows:
<1> Add the Keyword const before the type.
<2> must have initialization statements. The initialization value must be determined at compile time, usually a predefined simple type or an expression consisting of it, which can also be a null reference, but it cannot be a reference to an object because the object's reference is determined at run time (the object's reference, the new keyword that corresponds to the instance name of the class, to the memory request reference (address). A const is not a modifier, but a part of a core declaration that must precede a type.
Const Type Identifier=value;
c#3.0 var keyword