The best resources for developers

Is String.Format more efficient than StringBuilder?

public static string Format(IFormatProvider provider, string format, params object[] args)
    if ((format == null) || (args == null))
        throw new ArgumentNullException((format == null) ? "format" : "args");

    StringBuilder builder = new StringBuilder(format.Length + (args.Length * 8));
    builder.AppendFormat(provider, format, args);
    return builder.ToString();

Tags: c# performance stringbuilder string.format

Source: By lomaxx as answer to the question

This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 4.0

Related code-snippets: