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


tries to parse a string to an int, returns zero if it is unable to parse


public static int ToInt(this string current)
	int convertedValue;
	int.TryParse(current, out convertedValue);

	return convertedValue;


var someString = "5";
var someInt = someString.ToInt();

Author: Sean Biefeld

Submitted on: 10 nov. 2010

Language: C#

Type: System.String

Views: 4996