I would assume this is a common question but I couldn’t seem to find anything on SO or google.
Is it possible to only format a single argument. For example, format string foo = "{0} is {1} when {2}"; so that it returns read "{0} is cray when {2}"?
Intentions:
I am trying to format the string while overriding a method before it gets formatted in it’s base method
Success
Got it thanks to this answer, all answers were helpful :).
This unit test worked:
string foo = String.Format("{0} is {1} when {2}", "{0}", "cray", "{2}");
Assert.AreEqual("{0} is cray when {2}", foo);
string bar = string.Format(foo, "this", null, "it works");
Assert.AreEqual("this is cray when it works", bar);
Taking your question at face value, I suppose you could do the following:
That is, simply replace each unevaluated format item with itself.