Object-oriented (single-column mode)

Source: Internet
Author: User

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)

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.