Methods taking variable number of args (part 2)
In my previous post , I talked about the choice I made about taking a variable number of parameters. At that time, I used a simple params object[] , and the logic was built into the method (in the constructor of the underlying form in fact, but it is not relevant here). The problem with this approach is how to handle parameters with the same type but different meanings. A very simple example is the caption and the text of the InformationBox. Both are strings but how to differenciate between the two. I had to force the first parameter to be the text, but it was beginning to look like the MessageBox. For those who are familiar with C# 3.0, you may have already guessed what I could have used if .NET 3.5 had been available at that time. I could have used object initializers. It is a simple constructor syntax that allow the developer to specify only the properties he (or she) wants to define. For example, assuming the Client class is already defined with two properties "Name" and ...