using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { a a1 = new a(); Console.ReadKey(); } } class a { public a()//定義一個構造方法 { Console.Write("1"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { a a1 = new a("1"); Console.ReadKey(); } } class a { public a(string str)//定義一個構造方法 { Console.Write(str); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { a a1 = new a("1"); Console.ReadKey(); } } class a { /* public a()//如果自己不寫那么默認這個 { } */ public a(string str)//定義一個構造方法 { Console.Write(str); } } }