usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacesingle-column mode {//single-row mode//control a class can instantiate only one object//class Test//General Class//{ //public string name; //} //Data Access Classes classDbda { Public stringhost; Public stringdatabase; //a static member that is used to store the object of the class Public StaticDBDA db =NULL; //let the class not be instantiated PrivateDbda () {}//provides a method of making objects, static, to allow outside access to Public StaticDbda Duixiang () {if(db = =NULL) {db=NewDbda (); } returnDB; } } classProgram {Static voidMain (string[] args) { //Test T1 = new test (); //Test t2 = new Test (); //Dbda a = new Dbda (); Error, private constructor//Dbda db = Dbda. Duixiang (); //db.host = "localhost"; //Dbda db1 = Dbda. Duixiang (); //Console.WriteLine (); //Console.ReadLine (); //Interview Questions//three main features of object-oriented//Design Patterns } Static voidTest (intAintb) {Console.WriteLine (a+b); } //speech Function Method Static voidSpeak (intN) {//America (); //China (); //if (n = = 0)//{ //America (); //} //else if (n = = 1)//{ //China (); //} //else if (n = = 2)//{ //Hanyu (); //} } Static voidAmerica () {Console.WriteLine ("Hello"); } Static voidChina () {Console.WriteLine ("Hello"); } Static voidHanyu () {Console.WriteLine ("1234"); } }}
Object-oriented (single-column mode)