Child.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LeiheDuixiang
{
/// <summary>
/// 重载:同一个类里面,多个方法名字相同但参数(类型和数量)不同
/// </summary>
/// <param name="count">糖的数量</param>
public void EatSugar(int count)
{
if (count > 3)
{
Console.WriteLine("吃糖太多对牙齿不好!");
}else {
Console.WriteLine("好好吃糖吧!");
}
}
/// <summary>
///
/// </summary>
/// <param name="sugar">糖的类型</param>
/// <param name="count">糖的数量</param>
public void EatSugar(string sugar, int count)
{
if (sugar == "牛奶糖" && count > 2)
{
Console.WriteLine("牛奶糖不能吃太多呦");
}