Loli.cs
1 public class Loli 2 { 3 public string name; 4 public bool sex; 5 public int age; 6 public int height; 7 public int weight; 8 public void call() 9 { 10 Console.WriteLine("Master,started up,remove the bed!"); 11 } 12 public void cook() 13 { 14 Console.WriteLine("Master,delicious food..."); 15 } 16 }
Program.cs
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 Loli loli = new Loli(); 6 loli.name = "Alice"; 7 loli.sex = true; 8 loli.age = 14; 9 loli.height = 136; 10 loli.weight = 25; 11 Console.WriteLine("name\tsex\tage\theight\tweight"); 12 Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}",loli.name,loli.sex,loli.age,loli.height,loli.weight); 13 loli.call(); 14 loli.cook(); 15 } 16 }
世界上的万事万物皆为你的对象✿✿ヽ(°▽°)ノ✿
让我们来深入理解一下面向对象.[/微笑]
标签:Console,name,Loli,public,面向对象,WriteLine,loli From: https://www.cnblogs.com/ihoi/p/16970731.html