Format String

using System;
using System.Linq

public static class StringExtensions
{
    public static string Format(this string format, object arg, params object[] additionalArgs)
    {
        if (additionalArgs == null || additionalArgs.Length == 0)
        {
            return string.Format(format, arg);
        }
        else
        {
            return string.Format(format, new object[] { arg }.Concat(additionalArgs).ToArray());
        }
    }
}
Example:
string greeting = "Hello {0}, my name is {1}, and I own you."

Console.WriteLine(greeting.Format("Adam", "Microsoft"))

Description

Shortcut for System.String.Format

Details

Double click on the code to select all.

 

;