using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 重载
{
class Program
{
static void Main(string[] args)
{
Sayhello("baiya");
Sayhello();
Sayhello(1);
Console.ReadKey();
}
static void Sayhello(string str)
{
Console.WriteLine(str + "你好");
}
static string Sayhello()
{
Console.WriteLine("你好");
return "你好";
}
static string Sayhello(int i)
{
Console.WriteLine(i + "你好");
return "hello";
}
/* 错误 重载要求 参数的个数或参数的类型不同 和返回值无关
static string Sayhello(string str)
{
Console.WriteLine(i+"你好");
return "hello";
}
*/
}
}
c#学习笔记(八)-- 函数重载
最新推荐文章于 2024-01-15 09:44:27 发布