|
-
October 14th, 2008, 10:01 AM
#1
Precedence of "params" parameters vs normal parameters
Guys
Does anyone have a strategy they employ for providing overloads, one of which is a params, that potentially causes overload confusion?
I want to implement:
Code:
protected void A(string a){
A(a, "");
}
protected void A(string a, string b){
//do something
}
protected void A(string a, params object[] z){
A(string.Format(a, z));
}
protected void A(string a, string b, params object[] z){
A(string.Format(a, z), b);
}
And in calling code, existing we have stuff like:
A("The process failed")
A("The process failed: {0}", ex.Message)
I now want to upgrade:
A("The processed failed", "Errors Group");
A("The processed failed a status {1}: {0}", "Errors Group", ex.Message, obj.Status);
-
but of course, all that code that is:
A("The process failed: {0}", ex.Message)
Might call:
A(string, params object[] z)
And this is a silent problem, right?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|