Static SQL, dynamic SQL, and static SQL

Source: Internet
Author: User

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 ";
}
}

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.