1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace wintwelve 7 { 8 class cars 9 { 10 public string name; 11 12 public string color; 13 14 public string productplace; 15 16 17 public void show() 18 { 19 20 Console.WriteLine("汽车名称:{0} 颜色:{1} 产地:{2}",name,color,productplace); 21 } 22 } 23 }
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace wintwelve 7 { 8 class Program 9 { 10 static void Main(string[] args) 11 { 12 cars cs = new cars(); 13 Console.WriteLine("输入汽车名称:"); 14 cs.name = Console.ReadLine(); 15 Console.WriteLine("输入汽车颜色:"); 16 cs.color = Console.ReadLine(); 17 Console.WriteLine("输入汽车产地:"); 18 cs.productplace = Console.ReadLine(); 19 20 cs.show(); 21 Console.ReadLine(); 22 } 23 } 24 }