What methods in structure 3.5 have a signature of type String.Format?

I just noticed that I could do the following, which came as a complete surprise to me:

Console.WriteLine("{0}:{1}:{2}", "foo", "bar", "baz");

This also works for the method Write. What other methods support signatures without requiring use String.Format?

Debug.WriteLineno ... HttpResponse.WriteLineno ...

(And on the side of the note, I could not find a quick way to find this using Reflector . A way to search for specific signatures?)

Edit:

In particular, for the framework 3.5.

+5
source share
4 answers

, . TextWriter (, , StreamWriter StringWriter ) Write, .

, , StringBuilder.AppendFormat.

. , params, :

public void Foo(string message) {
    // whatever
}

public void Foo(string format, params string[] arg) {
    Foo(string.Format(format, arg));
}
+4

StringBuilder AppendFormat.

StringWriter , .

+4

Debug.WriteLine (string, params Object [] args) overload does this and is also added in .Net 4.0.

+1
source

The StringBuilder class has a method called AppendFormat that behaves in the same way.

0
source

All Articles