In addition Solution 1 and Solution 2.
This is the practical advice. Don't create a constructor with the signature
Test(List<string> args)</string>
, because it is not flexible enough. You could make it more flexible without any additional effort with one or two slightly different signatures.
Variant #1:
using System.Collections.Generic;
internal Test {
List list<string> = new List<string>();
internal Test(params string[] values) { list.AddRange(values); }
}
Test myTest1 = new Test("one parameter");
Test myTest2 = new Text("first parameter", "second parameter");
System.Collections.Generic.List<string> list =
Test myTestFromList = new Test(list.ToArray());
string[] array =
Test myTestFromArray = new Test(array);
Variant #2:
internal Test {
IList<string> list = new List<string>();
internal Test(System.Collections.Generic.IList<string> list) { this.list = list; }
}
Text myTestFromArray = new Test(array);
Test myTestFromList = new Test(list);
You can combine two constructors in one class, of course, but it can create ambiguity where the constructor calls are identical in first and second sample.
—SA