Click or drag to resize
Int32TryParse Method (String, NumberStyles, IFormatProvider, Int32)
Converts the string representation of a number in a specified style and culture-specific format to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static bool TryParse(
	string s,
	NumberStyles style,
	IFormatProvider provider,
	out int result
)

Parameters

s
Type: SystemString
A string containing a number to convert. The string is interpreted using the style specified by style.
style
Type: System.GlobalizationNumberStyles
A bitwise combination of enumeration values that indicates the style elements that can be present in s. A typical value to specify is Integer.
provider
Type: SystemIFormatProvider
An object that supplies culture-specific formatting information about s.
result
Type: SystemInt32
When this method returns, contains the 32-bit signed integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null, is not in a format compliant with style, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized.

Return Value

Type: Boolean
true if s was converted successfully; otherwise, false.
Exceptions
ExceptionCondition
ArgumentExceptionstyle is not a NumberStyles value. -or-style is not a combination of AllowHexSpecifier and HexNumber values.
See Also