I took the free time to read the course "C #2.0 sharp experience-Miscellaneous technology, and future development of C # Language" taught by Li Jianzhong. Some small knowledge points are reviewed and summarized. Here are the key points.
I. Introduction of namespace alias delimiters
C #2.0 allows us to use the namespace alias qualifier (: :) to avoid the conflict of type names in different namespaces.
1. When using the namespace alias qualifier (: :), the compiler can ensure that this is a qualifier only applicable to the "namespace alias" and will not be classified as another type or member qualifier (.)
2. the keyword globar can be placed on the left of the namespace alias qualifier (: :), which allows the compiler to only search for all namespaces, rather than other types or members. (The same namespace name and class name cause a conflict)
3. Use the namespace alias qualifier (: :) as much as possible, and reduce the use of general qualifiers such as the dot.
Ii. # pragma indicator
Code
[Obsolete]
Static void Foo (){}
Static void main (string [] ARGs)
{
# Pragma warning disable 612
Foo ();
# Pragma warning restore 612
}
Note:
1. Currently, only the Pragma indicator is supported # pragma warning
2. # pragma warning disable any compiler warning information
3. # pragma warning Restore can restore any compiler warning information that is disable.
4. You can follow the specific warning code after disable and restore to disable or recover specific warning information.
5. # pragma is a compiler preprocessing function that does not affect any code running mechanism.
Iii. Protection Level of the property accessors
C #2.0 allows us to use different access level modifiers for get and set accessors of an attribute:
Public string name
{
Get {return name ;}
Private set {name = value ;}
}
Note:
1. The access modifier of the application on the property accessor (get or set) must be "less than" (more strict), for example, protected is less than public
2. You can only specify the access modifier "smaller" than the access modifier "on an attribute accessor (get or set.
3. the attribute declaration in the interface cannot specify any access modifier for the attribute accessor (get or set). It can only be set to public by default.
4. The change rules at the protection level of the attribute accessors apply completely to the C # indexer (but the indexer cannot be declared as static ).
Best regards,
Charles Chen
Http://charles2008.cnblogs.com/