Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a C# method overload parameter ordering convention?

Is there any sort of convention in C# (or any object oriented language that supports method overloading) for the following situation?

Lets say I have a method foo:

public void Foo(int a){//does stuff}

But actually I have 3 methods foo:

public void Foo(int a){}
public void Foo(int a, double b){}
public void Foo(float c, int a, double b){}

Is there a convention that states whether or not the order of parameters matters in an overloaded method? Notice how the 3rd method doesn't an obvious logical progression (a,b,c).

like image 593
Dream Lane Avatar asked Feb 12 '13 20:02

Dream Lane


1 Answers

Yes there is. Have a look at https://msdn.microsoft.com/en-us/library/ms229029(v=vs.110).aspx

Do be consistent in the ordering of parameters in overloaded members. Parameters with the same name should appear in the same position in all overloads.

like image 136
delixfe Avatar answered Oct 07 '22 02:10

delixfe