C#方法重载 -0024

时间:2020-06-15 22:46:36   收藏:0   阅读:81

C#支持方法的重载:方法名相同,但是方法的参数或参数类型不同。

class ResultDisplayer
{
	public void DisplayResult(string result)
	{
		// implementation
	}

	public void DisplayResult(int result)
	{
		// implementation
	}
	public void DisplayResult(int result, int anotherResult)
	{
		// implementation
	}
}

注:方法名相同,然后下面两条满足其中一条即可

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!