Let's summarize the last delegates.
1.delegates
Delegates associates an event with an action or method. Encapsulates the member function. Equivalent to a pointer in C + +, but with more functionality than a pointer.
The structure is:delegate datatype methodname (object A,object b);
Delegates methods are:①Event handling: When an event occurs, the function is called;
② Callbacks: When an action is closed, the function is called;
1. Declaration and simple use.
1 Public Delegate voidDelegatedemo (String s);2 Static voidMain (string[] args)3 {4Delegatedemo dele =NewDelegatedemo (greeting);5Dele"hello!");6 }7 Static voidGreeting (strings)8 {9 Console.WriteLine (s);Ten}
The result is:
The same program variable is:
1 classGreetinghello2 {3 Public voidGreeting (strings)4 {5 Console.WriteLine (s);6 }7 }8 Public classSetarrbounds9 {Ten One Public Delegate voidDelegatedemo (String s); A Static voidMain (string[] args) - { -Greetinghello GH =NewGreetinghello (); theDelegatedemo dele =NewDelegatedemo (GH. greeting); -Dele"hello!"); - } - +}
The result is the same.
2.multicast Delegates multiple delegates
1 classGreetinghello2 {3 Public voidGreeting (strings)4 {5 Console.WriteLine (s);6 }7 Public voidSendgreetingtofile (strings)8 {9StreamWriter writer =Ten NewStreamWriter (@"C:\Users\lenovo\Desktop\delegates.txt"); One writer. WriteLine (s); A writer. Close (); - } - } the Public classSetarrbounds - { - - Public Delegate voidDelegatedemo (String s); + Static voidMain (string[] args) - { +Greetinghello GH =NewGreetinghello (); ADelegatedemo dele =NewDelegatedemo (GH. greeting); atDele + =NewDelegatedemo (GH. Sendgreetingtofile); -Dele"hello,delegates!"); - } - -}
Results:
3.thread Delegates Thread Delegation
4.anonymous Delegates anonymous method
That is, instead of declaring a complete class, use an anonymous class, which makes the code more concise and easy to understand. However, there are too many methods in the class.
1 Public Delegate voidDelegatedemo (String s);2 Static voidMain (string[] args)3 {4 5Delegatedemo dele =Delegate(strings)6 {7 Console.WriteLine (s);8 };9 TenDele"It ' s anonymous way~~"); One}
The result is:
Here's the new content
1.xml
1) XML (Extensible Markup Language), which can be used to tag data, define data types, is a source language that allows users to define their own markup language.
Comparison of XML with HTML (Hypertext Markup Language):
|
Whether the tag can be customized |
Whether or not to appear in pairs |
is case sensitive |
| Xml |
Is |
Is |
Is |
| Html |
Whether |
Whether |
Whether |
2) The first line of an XML document can be an XML declaration, and the start and end tags of the root element are used to enclose the contents of the XML document. A file can have only one root element, and it needs to be included with the wrapper. In the following example <recipe> is a follow element. When you build a document, the content and other tags must be placed <recipe> and </recipe> between.
1 <?xml version="1.0" encoding="utf-8"?> 2 <recipe>3 <recipename>ice Cream sundae</recipename>4 < Preptime>5 minutes</preptime>5 </recipe>
3) Naming elements
The English alphabet begins with spaces that are not allowed and must be consistent before and after.
4) Nesting elements
Make sure that the child elements are inside the parent element and cannot be interspersed with each other.
5) Adding attributes
Attributes are included in the <> name, enclosed in double quotation marks.
1<?xml version="1.0"encoding="Utf-8"?>2<recipe type="Dessert">3<recipename cuisine="American"servings="1">ice Cream sundae</recipename>4<preptime>5Minutes</preptime>5</recipe>
About creating XML documents can be in the foreground or in the background.
Related References http://www.cnblogs.com/jhxk/articles/1872930.html
2.LINQ (Language Integrated query)
is to use C # code to query the database.
Because LINQ is not connected to MySQL by default, but my computer does not have SQL Server, only MySQL, so Baidu a bit how LINQ for MySQL.
First download install mysql-connector-net, then restart the computer, open vs after the right-click Data connection in Server Explorer, add links, the following window will appear: click MySQL
Then enter your server name, and user Name,password can add success.
(note here, this is required to have the password of the user name, and MySQL used when the default root no password login, change password must be Baidu good to change, do not blindly change, the next is unloading MySQL reload (blood lesson ah!) ), or you can create a new user for a specific database yourself ( recommended ))
Item--New Add Item-->ado. NET Entity Data Model
Then all the way "next", you can run the ~ ~ Effect as follows (simply built three table, no import data)
End
Delegates && XML && LINQ