C# 中方法重载的不同方法是什么?
一个方法可以重载的不同方法有 −
The datatypes of parameters are different The number of parameters are different
以下给出了一个说明不同数据类型参数的示例 −
void print(int i) {
Console.WriteLine("Printing int: {0}", i );
}
void print(double f) {
Console.WriteLine("Printing float: {0}" , f);
}
void print(string s) {
Console.WriteLine("Printing string: {0}", s);
}以下说明了不同的参数数量 −
// two parameters
public static int mulDisplay(int one, int two) {
return one * two;
}
// three parameters
public static int mulDisplay(int one, int two, int three) {
return one * two * three;
}
// four parameters
public static int mulDisplay(int one, int two, int three, int four) {
return one * two * three * four;
}
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP