C #8. Basic Knowledge,
C #8. Basic Knowledge
Prepared by Zhu, reproduced please indicate from Zhu jiayuan http://blog.csdn.net/zhgl7688
1. There are three enumeration types: Non-generic interface (IEnumerator/IEnumerable Interface), generic interface (IEnumerator <T>/IEnumerable <T> Interface), and no interface.
2. The IEnumerator Interface contains three function members: current returns the current position item (read-only attribute ), movenext indicates whether the new position is valid by returning a Boolean value from the method prior to the position of the enumerative number, and the reset method resets the position to the original state.
3. To create an enumerative number class for a non-generic interface, you must declare the class that implements the IEnumerator interface. The interface class has three methods: Current, MoveNext, and Reset, which are System. A member of the Collections namespace.
4. The IEnumerable interface has only one member GetEnumerator method, which returns the number of enumerated objects.
5. Differences between the generic enumeration interface and the non-generic enumeration interface: the former implements the current attribute and returns an object reference. The latter returns objects of the actual type.
6. The generic enumeration interface inherits from two interfaces: Non-generic IEnumerator interface and IDisposable interface.
7. The IDisposable interface only has a void-type non-parameter method for Dispose, which is used to release unmanaged resources.
8. The iterator is a code block containing one or more yield statements. There are three types of code: method subject, accesser subject, and operator subject.
9. The iterator has two special statements: the yieldreturn statement executes the next item returned in the sequence. The Yield break statement specifies that there are no more entries in the sequence.
10. The iterator must use the System. Colletions. Generic namespace, which is referenced by using.
11,
12. generic delegation: declares that the generic delegation contains a list of type parameters in angle brackets between the delegate name and the delegate parameter list.
13. The type parameter list includes the return value, form parameter table, and constraint clause. The type returned by the delegate is at the end of the parameter table.
14. When the compiler can infer a type parameter from a method parameter, it can omit the type parameter and the angle brackets in the call.
15. Extension methods of generic classes: they must be declared as static and static class members. The first parameter type must contain the keyword "this", followed by the name of the extended generic class.
16. LINQ is a new feature integrated into C # and VB. NET to provide data query capabilities. Query data sets in the form of database queries. Allows you to query data from databases, program object sets, and XML documents.
Prepared by Zhu, reproduced please indicate from Zhu jiayuan http://blog.csdn.net/zhgl7688