-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Strings_StringExtensions_ToInt32
Converts the string representation of a number in a specified style and culture-specific format to its Int32 equivalent. A return value indicates whether the conversion succeeded.
Namespace: CodeJam.Strings
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static Nullable<int> ToInt32(
this string str,
NumberStyles numberStyle = NumberStyles.Integer,
IFormatProvider provider = null
)
VB
<ExtensionAttribute>
Public Shared Function ToInt32 (
str As String,
Optional numberStyle As NumberStyles = NumberStyles.Integer,
Optional provider As IFormatProvider = Nothing
) As Nullable(Of Integer)
F#
[<ExtensionAttribute>]
static member ToInt32 :
str : string *
?numberStyle : NumberStyles *
?provider : IFormatProvider
(* Defaults:
let _numberStyle = defaultArg numberStyle NumberStyles.Integer
let _provider = defaultArg provider null
*)
-> Nullable<int>
- str
- Type: System.String
A string containing a number to convert. The string is interpreted using the style specified by numberStyle. - numberStyle (Optional)
- Type: System.Globalization.NumberStyles
A bitwise combination of enumeration values that indicates the style elements that can be present in str. Default value is Integer. - provider (Optional)
- Type: System.IFormatProvider
An object that supplies culture-specific formatting information about str.
Type: Nullable(Int32)
When this method returns, contains the Int32 value equivalent of the number contained in str, if the conversion succeeded, or null if the conversion failed. The conversion fails if the str parameter is null or String.Empty, is not in a format compliant withstyle, or represents a number less than MinValue or greater than MaxValue.
In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).