G
Guest
Hi everybody,
I need simple string formatting like string.Format() does, but just with
strings what seems not to work.
Can anyone tell me please why this doesn't work and how can it be done? This
looked like the simple and good solution but no.
class Example
{
string format = "{1} {2} {3}"
string anotherFormat = "{3}{1}{2}";
public void Test()
{
Print(format);
Print(anotherFormat);
}
private void Print(string rightFormat)
{
// Here goes FormatException: Input string was not in a correct format
Console.WriteLine(string.Format(rightFormat, "one", "two", "three"));
}
}
Thank you in advance.
I need simple string formatting like string.Format() does, but just with
strings what seems not to work.
Can anyone tell me please why this doesn't work and how can it be done? This
looked like the simple and good solution but no.
class Example
{
string format = "{1} {2} {3}"
string anotherFormat = "{3}{1}{2}";
public void Test()
{
Print(format);
Print(anotherFormat);
}
private void Print(string rightFormat)
{
// Here goes FormatException: Input string was not in a correct format
Console.WriteLine(string.Format(rightFormat, "one", "two", "three"));
}
}
Thank you in advance.