ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods


This method takes away the need for writing two lines for TryParse and gives users an option of returning a default number.


public static int TryParse(this string input, int defaultValue)
    int value;
    if (Int32.TryParse(input, out value))
        return value;
    return defaultValue;



Author: Avik

Submitted on: 7 jun 2012

Language: C#

Type: System.Int32

Views: 8202