C# Class NSupport.StringToNumberConversion

Provides extension methods for String for conversion and checking to other types.
Show file Open project: jittuu/NSupport

Public Methods

Method Description
AsDecimal ( this source ) : decimal?

Return converted Decimal if successfully parsed, otherwise null (Nothing in Visual Basic).

AsDecimal ( this source, NumberStyles style ) : decimal?

Return converted Decimal if successfully parsed, otherwise null (Nothing in Visual Basic).

AsDouble ( this source ) : double?

Return converted Double if successfully parsed, otherwise null (Nothing in Visual Basic).

AsDouble ( this source, NumberStyles style ) : double?

Return converted Double if successfully parsed, otherwise null (Nothing in Visual Basic).

AsInt32 ( this source ) : int?

Return converted Int32 if successfully parsed, otherwise null (Nothing in Visual Basic).

AsInt32 ( this source, NumberStyles style ) : int?

Return converted Int32 if successfully parsed, otherwise null (Nothing in Visual Basic).

AsInt64 ( this source ) : long?

Return converted Int64 if successfully parsed, otherwise null (Nothing in Visual Basic).

AsInt64 ( this source, NumberStyles style ) : long?

Return converted Int64 if successfully parsed, otherwise null (Nothing in Visual Basic).

IsNumber ( this source ) : bool

Return whether the provided String is number. It call overload method with this combination of NumberStyles (NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands;).

IsNumber ( this source, NumberStyles style ) : bool

Return whether the provided String is number with provided NumberStyles.

ToDecimal ( this source ) : decimal

Return converted Decimal.

ToDecimal ( this source, NumberStyles style ) : decimal

Return converted Decimal.

ToDouble ( this source ) : double

Return converted Double.

ToDouble ( this source, NumberStyles style ) : double

Return converted Double.

ToInt32 ( this source ) : int

Return converted Int32.

ToInt32 ( this source, NumberStyles style ) : int

Return converted Int32.

ToInt64 ( this source ) : long

Return converted Int64.

ToInt64 ( this source, NumberStyles style ) : long

Return converted Int64.

Method Details

AsDecimal() public static method

Return converted Decimal if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsDecimal ( this source ) : decimal?
source this A instance.
return decimal?

AsDecimal() public static method

Return converted Decimal if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsDecimal ( this source, NumberStyles style ) : decimal?
source this A instance.
style NumberStyles A to parse against .
return decimal?

AsDouble() public static method

Return converted Double if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsDouble ( this source ) : double?
source this A instance.
return double?

AsDouble() public static method

Return converted Double if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsDouble ( this source, NumberStyles style ) : double?
source this A instance.
style NumberStyles A to parse against .
return double?

AsInt32() public static method

Return converted Int32 if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsInt32 ( this source ) : int?
source this A instance.
return int?

AsInt32() public static method

Return converted Int32 if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsInt32 ( this source, NumberStyles style ) : int?
source this A instance.
style NumberStyles A to parse against .
return int?

AsInt64() public static method

Return converted Int64 if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsInt64 ( this source ) : long?
source this A instance.
return long?

AsInt64() public static method

Return converted Int64 if successfully parsed, otherwise null (Nothing in Visual Basic).
public static AsInt64 ( this source, NumberStyles style ) : long?
source this A instance.
style NumberStyles A to parse against .
return long?

IsNumber() public static method

Return whether the provided String is number. It call overload method with this combination of NumberStyles (NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands;).
public static IsNumber ( this source ) : bool
source this A instance.
return bool

IsNumber() public static method

Return whether the provided String is number with provided NumberStyles.
public static IsNumber ( this source, NumberStyles style ) : bool
source this A instance.
style NumberStyles A to check against .
return bool

ToDecimal() public static method

Return converted Decimal.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than .
public static ToDecimal ( this source ) : decimal
source this A instance.
return decimal

ToDecimal() public static method

Return converted Decimal.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than . Throws when is not valid
public static ToDecimal ( this source, NumberStyles style ) : decimal
source this A instance.
style NumberStyles A to parse against .
return decimal

ToDouble() public static method

Return converted Double.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than .
public static ToDouble ( this source ) : double
source this A instance.
return double

ToDouble() public static method

Return converted Double.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than . Throws when is not valid
public static ToDouble ( this source, NumberStyles style ) : double
source this A instance.
style NumberStyles A to parse against .
return double

ToInt32() public static method

Return converted Int32.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than .
public static ToInt32 ( this source ) : int
source this A instance.
return int

ToInt32() public static method

Return converted Int32.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than . Throws when is not valid
public static ToInt32 ( this source, NumberStyles style ) : int
source this A instance.
style NumberStyles A to parse against .
return int

ToInt64() public static method

Return converted Int64.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than .
public static ToInt64 ( this source ) : long
source this A instance.
return long

ToInt64() public static method

Return converted Int64.
Throws when is null. Throws when is not correct format. Throws when represents a number less than or greater than . Throws when is not valid
public static ToInt64 ( this source, NumberStyles style ) : long
source this A instance.
style NumberStyles A to parse against .
return long