the datatypes of parameters are differentthe 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 parameterspublic static int muldisplay(int one, int two) { return one * two;}// three parameterspublic static int muldisplay(int one, int two, int three) { return one * two * three;}// four parameterspublic static int muldisplay(int one, int two, int three, int four) { return one * two * three * four;}
以上就是c# 中重载方法有哪些不同的方式?的详细内容。
