![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Emmet 8 { 9 class emmet 10 { 11 public emmet(string name) 12 { 13 this.Name = name; 14 } 15 16 public string Name { get; set; } 17 18 public void showInfo() 19 { 20 Console.WriteLine("大家好!我是一只小蚂蚁,名叫"+this.Name); 21 } 22 23 public void FindDessert(Dessert dessert) 24 { 25 Console.WriteLine("我找到一块甜品:"+dessert.dessertName); 26 } 27 28 public void CarryDessert() 29 { 30 Console.WriteLine("现在,大家搬运甜品!"); 31 Console.WriteLine("我们完成寻找甜品的任务!"); 32 } 33 } 34 }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Emmet 8 { 9 class Dessert 10 { 11 public Dessert(string dessertName) 12 { 13 this.dessertName = dessertName; 14 } 15 16 public string dessertName { get; set; } 17 } 18 }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Emmet 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 emmet Emmet = new emmet("小不点"); 14 Dessert dessert = new Dessert("提拉米苏"); 15 Emmet.showInfo(); 16 Emmet.FindDessert(dessert); 17 Emmet.CarryDessert(); 18 19 Console.Read(); 20 21 } 22 } 23 }