SharpExtensions is a Utility library that provides a big mess of useful extension functions and other goodies.
1.0
SharpExtensions is designed to be distributed with little to no dependencies on other libraries. However, Jet Brains' Code Annotations are used, but have been included in the SharpExtensions source.
An extension method for the string type which allows invocation on a string literal.
// Implemenetation
[Pure, NotNull, StringFormatMethod("format")]
public static string Build([NotNull] this string format, params object[] arguments)
{
if (format == null || arguments == null)
{
throw new ArgumentNullException(format == null ? "format" : "arguments");
}
return arguments.Length > 0 ? string.Format(format, arguments) : format;
}
// Usage
public static int MultiplyAndPrint(int a, int b)
{
var result = a * b;
var message = "{0} x {1} = {2}".Build(a, b, result);
Console.WriteLine(message);
return result;
}
var ten = MultiplyAndPrint(2, 5);
// Output: "2 x 5 = 10"