In C# I've a case where I'm looking to generalize string formatting of the following type:
string original = "[{0}] is a parent of [{1}] who is the brother of [{2}] who is..";
List<string> args = new List<string>() {"Alice", "Bob", "Charlie", "Doug"};
string formattedString = String.Format(original, args);
Expected output would be:
Alice is a parent of Bob who is the brother of Charlie who is..
The main challenge here is, original
string can have unknown number of variables, given that List args
is always supposed to have higher or equal count than the number of variables in original
string, how can I make this work?