Dynamic string formatting in c#
问题 I created log method that accept string. When I want to use it I write something like: Log(string.Format("Message {0}", AdditionalInfo)); How should I implement Log method in order to be able to use string Format but do not have to write it explicitly in method arguments: Log("Message {0}", AdditionalInfo); I use .net 2.0 回答1: public void Log(string formatString, params object[] parameters) { Log(String.Format(formatString, parameters)); } 回答2: public void Log(string format, params object[]