Overview
· MAIN method is the entry point of the program, and the program is controlled to start and end in this method.
· This method is in the internal statement of class or structure. It must be a static method without a public method. (In the example above, it accepts the default access level private.
· It can have a VOID or INT return type.
· Declare the MAIN method or use parameters or without parameters.
• The parameter can be read as a command line parameter from zero start index.
· Unlike C and C , the name of the program will not be regarded as the first command line parameter.
Data Type Overview
Data types can be described as:
· Built-in data type, such as Int or Char,
· User defines data types such as Class or Interface.
· The data type can also be defined as:
· Value type (C # 2005 Reference) (for stored value),
· Reference Type (C # 2005 Reference) (used to store references to actual data).
Array Overview
The array has the following properties:
· The array can be one-dimensional, multi-dimensional or interlaced.
• The default value of the value array element is set to zero, and the default value of the reference element is set to NULL.
• The interleave array is an array of arrays, so its element is a reference type, which is initialized to NULL.
• Array index from zero: index of an array with N elements is from 0 to N-1.
· Array elements can be any type, including an array type.
· The array type is a reference type from abstract base type Array. Since this type implements IEnumerable and IEnumerable, ForeA iteration can be used to all arrays in C # 2005.
Overview
Objects, classes, and structures have the following features:
• The object is an instance of a given data type. When performing an application, the data type provides a blueprint for the object that creates (or instantiated).
· The new data type is defined using classes and structures.
• Class and structure (including code and data) form a generation block of C # 2005 applications. C # 2005 application always contains at least one class.
· Structure can be considered lightweight, is an ideal choice for creating data types for storing small amounts of data, and may not indicate the type of expansion inheritance.
· C # 2005 class support inheritance, which means they can derive from the previously defined classes.
Property overview
• Attributes enables classes to acquire and set values in a disclosed method while hiding implementation or verifying code.
• Get Attribute Accessor is used to return attribute values, while the SET Accessor is used to assign a new value. These accessors can have different access levels. For more information, see Accessor Accessibility.
The value keyword is used to define the value assigned by the SET indexer.
· The attributes that do not implement the SET method are read-only.
Indexer overview
The indexer allows the object to index according to a similar approach.
· GET accessor returns the value. Set Accessor Assign Value.
· The THIS keyword is used to define the indexer.
The value keyword is used to define the value assigned by the SET indexer.
• The indexer does not have to index according to the integer value, and you decide how to define a specific lookup mechanism.
• The indexer can be overloaded.
• The indexer can have multiple ginseng, such as when accessing a two-dimensional array.
Event overview
The event has the following features:
• The event is a way class to notify the object needs to perform some operation.
• Although the event is also useful at other times (such as signal status changes), the event is usually used in the graphical user interface. • The event usually declares the delegate handler.
• The event can call an anonymous method to replace the delegate. For more information, see anonymous methods.
Iterator Overview
· Iterator is a piece of code that can return the ordered sequence of the same type of value.
· Iterator can be used as a method, operator, or a Code body of the GET accessor.
· Iterator code uses Yield Return statements to return each element in turn. Yield Break will terminate iteration. See yield for more information.
• Multiple iterators can be implemented in the class. Each iterator must have a unique name as any class member, and can be called by the client code in the foreach statement, as shown below: Foreach (int x in sampleclass.ITerator2) {}
· The return type of iterator must be IEnumerable, IEnumerator, IEnumerable, or IEnumerator.
Yield keyword is used to specify the returned value. When you reach the Yield Return statement, the current location is saved. The next time you call an iterator, you will start executing from this location.
The iterator is particularly useful for the collection class, which provides a simple method to iterate an uncommon data structure (such as binary tree).
Namespace overview
Namespace has the following properties:
· Organize large code projects.
· Divide the operator.
Using Directive means that you don't need to specify namespace names for each class.
· Global namespace is "root" namespace: global :: System Always reference the .NET Framework namespace System.
Space-saving type overview
The air type has the following characteristics:
• The blackening type indicates a value type variable that can be assigned a NULL value. Unable to create a space-free type based on the reference type. (The reference type has supported a NULL value.).
· Syntax T? Is the shorthand of System.Nullable
· The same method assigns the value of the blamed type with the value assigned to the average value type, such as int? X = 10; or double? D = 4.108 ;.
· If the value of the basic type is NULL, use the System.null.GetValueOrDefault property to return the value or default value assigned to the base type, such as Int j = x.GetValueOrDefault ();
· Please use the Hasvalue and Value read-only properties to test whether it is empty and retrieved, such as if (x.haasvalue) j = x.Value;
o If this variable contains a value, the Hasvalue property returns true; or if the value of this variable is empty, then returns false.
o If you have already assigned it, the value attribute returns this value, otherwise System.INValidOperationException will be triggered.
o The default value of the blank type variable sets HasValue to False. Value is not defined.
· Use the operator to assign default values, the current value is empty type, which is assigned to non-empty type, such as int? X = null; int y = x ?? -1 ;.
• Nesting can be used. Will not compile the following line: nullable
Unsafe code overview
Unsafe code has the following properties:
· Method, type, and code blocks that can be defined as unsafe.
· In some cases, the unsafe code can improve the performance of the application by removing the array boundary check. · When the native function of the needle is called, it is necessary to use an unsafe code.
· Use unsafe code will cause security risks and stability risks.
· In C # 2005, in order to compile unsafe code, the application must be compiled with / unsafe.
Application domain overview
The application domain has the following features:
· You must first load the assembly into the application domain before you can execute the assembly. For more information, see the assembly and global assembly cache (C # 2005 Programming Guide).
· An error in an application domain does not affect other code running in another application domain.
• Can stop a single application and uninstall code without stopping the entire process. You cannot uninstall a separate assembly or type, you can only uninstall the entire application domain.
Contection overview
The assembly has the following features:
· The assembly is implemented as a .exe or .dll file.
· You can share the assembly between multiple applications by placing the program set in the global program cache.
· To put the assembly in the global assembly cache, you must have a strong naming assembly. For more information, see the assembly with strong names.
• The assembly is only loaded into memory only when needed.
· You can use reflection to programmatically obtain information about the assembly. For more information, see the topic reflection.
• If the purpose of the load assembly is only checked, the method such as ReflectiononlyLoadFrom should be used.
· Two versions of the same assembly can be used in a single application. See the Extern alias for more information.
Property overview
The attribute has the following features:
• The property can add metadata to the program. Metadata is information in embedded programs such as compiler instructions or data descriptions.
· Program can use reflection to check your metadata. See Using Reflection Access Properties.
· Usually used attributes and COM interaction
Collection class overview
The collection class has the following characteristics:
• The set class is defined as part of the system.collections or system.collections.Generic namespace.
· Most set classes are derived from Icollection, IComparer, IEnumerable, ILIST, iDictionary, and iDictionaryEnumerator interface and their equivalent flock.
· Using generic set classes can provide higher type security, in some cases, better performance, especially when stored value types, these advantages will be more obvious. For more information, see the advantages of generics.
Abnormal overview
An exception has the following features:
• An exception is generated when an application encounters an abnormal condition (such as the zero-free condition or memory is not alert).
• When an exception occurs, the control flow immediately jumps to the associated exception handler (if present).
· If a given exception has no exception handler, the program will stop execution and display an error message.
· It may cause an exception to perform through the TRY keyword.
• The abnormal handler is the code block executed when an exception occurs. In C # 2005, the catch keyword is used to define an exception handler.
· The program can explicitly trigger an exception using the THROW keyword.
• The abnormal object contains detailed information about the error, including the status of the call stack and text description for the error.
· Even if an exception is triggered, the code in the Finally block will execute so that the program can release resources.
Thread overview
The thread has the following characteristics:
• Threads make C # 2005 program to perform concurrent processing.
· .NET Framework's System.Threading Namespace makes threads easier to use. · Thread sharing application resources. For more information, see Using Threads and Thread Processing.
Reflection overview
Reflection is useful in the following cases:
· The properties of the program metadata need to be accessed. See the topic using the reflection access attribute.
· Check and instantiate the types in the assembly.
· Build a new type at runtime. Use the classes in System.Reflection.emit.
· Perform later bindings, access the type of type created at runtime. See the topic Dynamic Loading and Using Types.