MSXML and ADO. Net allow us to traverse and operate XML documents, but they do not make developers feel comfortable and natural when writing data access code.
Data access has become an advanced programming concept in. net.Smart sensingTechnology to createType-safe data access codeAndSyntax check during compilation.
The Using statement is a concise representation of try... finally. When the created type implements idisposable, you can directly use using.
Anonymous Method)
// Create a handler for a click event
button1.Click += delegate(System.Object o, System.EventArgs e)
{ System.Windows.Forms.MessageBox.Show("Click!"); };
Object and set initializer syntaxThe compiler converts the set initialization code into a complete form, saving a lot of coding time. P28: Inside Story of LINQ Programming
Chapter 3:Extension Method(Extension Method): it allows extension of the sealing class and internal type. It can also avoid the deep inheritance tree. It provides a way to add behavior without inheritance.
The example shows how to add an extension method named dump,The this modifier must be used before the first parameter type.
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. reflection;
Using system. diagnostics;
Namespace consoleapplication2
{
Class Program
{
Static void main (string [] ARGs)
{
VaR Song = new {artist = "Jussi", Song = "Aida "};
Song. Dump ();
Console. Read ();
}
}
Public static class Dumper
{
Public static void dump (This object o) // Applies to the object type, and all types are inherited from the object.
{
Propertyinfo [] properties = O. GetType (). getproperties ();
Foreach (propertyinfo P in properties)
{
Try
{
Debug. writeline (string. Format ("Name: {0}, value: {1}", p. Name,
P. getvalue (O, null )));
}
Catch
{
Debug. writeline (string. Format ("Name: {0}, value: {1}", p. Name,
"Unk ."));
}
}
}
Public static void dump (this ilist List)
{
Foreach (Object o in List)
O. Dump ();
}
}
}
P60 ~ The Comparison Between 64 examples 3-6 and 3-8 shows that the code is more concise. The foundation of LINQ is the extension method (and generic), and where is an extension method used to extend iqueryable.
Chapter 4: The yield return keyword phrase can make an object that is not an iterative set into an iterative set. It cannot appear in catch blocks or try blocks with one or more catch clauses. Yield statements cannot appear in anonymous methods.
Chapter 5:
1.
Delegate void functionpointer (string Str );
Functionpointer fp = s => console. writeline (s );
FP ("Hello World ");
2.
System. Action <string> fp = s => console. writeline (s );
FP ("Hello World ");
Func is used to execute an operation on the parameter and return a value;
Predicate defines a set of conditions and determines whether the parameters meet these conditions.