Static SQL, dynamic SQL, and static SQL
Static
1. Common Member
Common members belong to objects.
Call with object
2. Static members
Static members belong to the class
Called by Class Name
Class FenBi
{
Public int length; // common member
Public string color ;//
}
Static keywords
Static methods cannot contain common members.
The common method can contain static members.
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;
Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
ZuHe zh = new ZuHe ();
// Zh. name = "James"; // call a common member
// ZuHe. zname = "May"; // call a static member
ZuHe. Sing ();
1. For ease of use
When connecting to the database, create a connection object class and use static properties to directly return the connection object.
2. transfer information between two classes
3. Classes of objects cannot be created (there is a limit on the number of objects to be created)
Console. WriteLine (zh. Run ());
Console. ReadLine ();
}
}
Class ZuHe
{
Public string name = ""; // common member, the name of a person in the combination
Public static string zname = ""; // static member, combination name
Public static string Sing () // static method
{
Return "singing ";
}
Public string Run () // common member
{
Return zname + "running ";
}
}
}