Dienstag, 17. März 2020

Pass string parameter plus optional placeholder fill up arguments to a method - method signature for String.Format(..)

how to setup a method getting args to be applied using String.Format(....)?

Example:

        private void log(object text, params object[] param)
        {
            string line;
            if (param != null && param.Length > 0)
                line = String.Format(text.ToString(), param);
            else
                line = text.ToString();
            if (Environment.UserInteractive==true)
                Console.WriteLine(line);
        }

Keine Kommentare:

Kommentar veröffentlichen