Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Extensions.StringConvertExtensions Class Reference

String custom methods which are used to convert the string to another type More...

Static Public Member Functions

static int ToIntParsed (this string value, string name)
 Converts a string value into an integer, using ParseInt function similar to Javascript (eg. 12ab3 = 12) More...
 
static int ToIntParsed (this string value, int defaultValue)
 Converts a string value into an integer, using ParseInt function similar to Javascript (eg. 12ab3 = 12) More...
 
static int ToInt (this string value, string name)
 Converts a string value into an integer More...
 
static int ToInt (this string value, int defaultValue)
 Converts a string value into an integer More...
 
static ? int ToNullableInt (this string value, string name)
 Converts a string value into a nullable integer More...
 
static ? int ToNullableInt (this string value, int? defaultValue=null)
 Converts a string value into a nullable integer More...
 
static short ToShort (this string value, string name)
 Converts a string value into a short More...
 
static short ToShort (this string value, short defaultValue)
 Converts a string value into a short More...
 
static ? short ToNullableShort (this string value, string name)
 Converts a string value into a nullable short More...
 
static ? short ToNullableShort (this string value, short? defaultValue=null)
 Converts a string value into a nullable short More...
 
static long ToLong (this string value, string name)
 Converts a string value into a long More...
 
static long ToLong (this string value, long defaultValue)
 Converts a string value into a long More...
 
static ? long ToNullableLong (this string value, string name)
 Converts a string value into a nullable long More...
 
static ? long ToNullableLong (this string value, long? defaultValue=null)
 Converts a string value into a nullable long More...
 
static ulong ToULong (this string value, string name)
 Converts a string value into a ulong More...
 
static ulong ToULong (this string value, ulong defaultValue)
 Converts a string value into a ulong More...
 
static ? ulong ToNullableULong (this string value, string name)
 Converts a string value into a nullable ulong More...
 
static ? ulong ToNullableULong (this string value, ulong? defaultValue=null)
 Converts a string value into a nullable ulong More...
 
static double ToDouble (this string value, string name)
 Converts a string value into a double More...
 
static double ToDouble (this string value, double defaultValue)
 Converts a string value into a double More...
 
static ? double ToNullableDouble (this string value, string name)
 Converts a string value into a nullable double More...
 
static ? double ToNullableDouble (this string value, double? defaultValue=null)
 Converts a string value into a nullable double More...
 
static decimal ToDecimal (this string value, string name)
 Converts a string value into a decimal More...
 
static decimal ToDecimal (this string value, decimal defaultValue)
 Converts a string value into a decimal More...
 
static ? decimal ToNullableDecimal (this string value, string name)
 Converts a string value into a nullable decimal More...
 
static ? decimal ToNullableDecimal (this string value, decimal? defaultValue=null)
 Converts a string value into a nullable decimal More...
 
static float ToFloat (this string value, string name)
 Converts a string value into a float More...
 
static float ToFloat (this string value, float defaultValue)
 Converts a string value into a float More...
 
static ? float ToNullableFloat (this string value, string name)
 Converts a string value into a nullable float More...
 
static ? float ToNullableFloat (this string value, float? defaultValue=null)
 Converts a string value into a nullable float More...
 
static bool ToBool (this string value, string name)
 Converts a string into a bool More...
 
static bool ToBool (this string value, bool defaultValue)
 Converts a string into a bool More...
 
static ? bool ToNullableBool (this string value, string name)
 Converts a string into a nullable bool More...
 
static ? bool ToNullableBool (this string value, bool? defaultValue=null)
 Converts a string into a nullable bool More...
 
static DateTime ToDateTime (this string value, string name)
 Converts a string value into a datetime More...
 
static DateTime ToDateTime (this string value, DateTime defaultValue)
 Converts a string value into a datetime More...
 
static ? DateTime ToNullableDateTime (this string value, string name)
 Converts a string value into a nullable datetime More...
 
static ? DateTime ToNullableDateTime (this string value, DateTime? defaultValue=null)
 Converts a string value into a nullable datetime More...
 
static char ToChar (this string value, string name)
 Converts a string value into a char More...
 
static char ToChar (this string value, char defaultValue)
 Converts a string value into a char More...
 
static ? char ToNullableChar (this string value, string name)
 Converts a string value into a nullable char More...
 
static ? char ToNullableChar (this string value, char? defaultValue=null)
 Converts a string value into a nullable char More...
 
static Guid ToGuid (this string value, string name)
 Converts a string value into a Guid More...
 
static Guid ToGuid (this string value, Guid defaultValue)
 Converts a string value into a Guid More...
 
static ? Guid ToNullableGuid (this string value, string name)
 Converts a string value into a nullable Guid More...
 
static ? Guid ToNullableGuid (this string value, Guid? defaultValue=null)
 Converts a string value into a nullable Guid More...
 
static T ToEnum< T > (this string str)
 Casts a string to an enum More...
 
static T ToEnum< T > (this string str, T defaultValue)
 Casts a string to an enum More...
 
static Color ToColor (this string value, string name)
 Converts a string value into a Color More...
 
static Color ToColor (this string value, Color defaultValue)
 Converts a string value into a Color More...
 
static ? Color ToNullableColor (this string value, string name)
 Converts a string value into a Color More...
 
static ? Color ToNullableColor (this string value, Color? defaultValue=null)
 Converts a string value into a Color More...
 

Detailed Description

String custom methods which are used to convert the string to another type

Member Function Documentation

◆ ToBool() [1/2]

static bool Sphyrnidae.Common.Extensions.StringConvertExtensions.ToBool ( this string  value,
bool  defaultValue 
)
static

Converts a string into a bool

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted true/false (or defaultValue)

◆ ToBool() [2/2]

static bool Sphyrnidae.Common.Extensions.StringConvertExtensions.ToBool ( this string  value,
string  name 
)
static

Converts a string into a bool

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted true/false

◆ ToChar() [1/2]

static char Sphyrnidae.Common.Extensions.StringConvertExtensions.ToChar ( this string  value,
char  defaultValue 
)
static

Converts a string value into a char

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted char value (or defaultValue)

◆ ToChar() [2/2]

static char Sphyrnidae.Common.Extensions.StringConvertExtensions.ToChar ( this string  value,
string  name 
)
static

Converts a string value into a char

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted char value

◆ ToColor() [1/2]

static Color Sphyrnidae.Common.Extensions.StringConvertExtensions.ToColor ( this string  value,
Color  defaultValue 
)
static

Converts a string value into a Color

Parameters
valueThe string to convert
defaultValueIf the value is somehow bad, this will be returned instead
Returns
The converted Color (or defaultValue)

◆ ToColor() [2/2]

static Color Sphyrnidae.Common.Extensions.StringConvertExtensions.ToColor ( this string  value,
string  name 
)
static

Converts a string value into a Color

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error)
Returns
The converted Color

◆ ToDateTime() [1/2]

static DateTime Sphyrnidae.Common.Extensions.StringConvertExtensions.ToDateTime ( this string  value,
DateTime  defaultValue 
)
static

Converts a string value into a datetime

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted datetime value (or defaultValue)

◆ ToDateTime() [2/2]

static DateTime Sphyrnidae.Common.Extensions.StringConvertExtensions.ToDateTime ( this string  value,
string  name 
)
static

Converts a string value into a datetime

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted datetime value

◆ ToDecimal() [1/2]

static decimal Sphyrnidae.Common.Extensions.StringConvertExtensions.ToDecimal ( this string  value,
decimal  defaultValue 
)
static

Converts a string value into a decimal

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted decimal value (or defaultValue)

◆ ToDecimal() [2/2]

static decimal Sphyrnidae.Common.Extensions.StringConvertExtensions.ToDecimal ( this string  value,
string  name 
)
static

Converts a string value into a decimal

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted double value

◆ ToDouble() [1/2]

static double Sphyrnidae.Common.Extensions.StringConvertExtensions.ToDouble ( this string  value,
double  defaultValue 
)
static

Converts a string value into a double

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted double value (or defaultValue)

◆ ToDouble() [2/2]

static double Sphyrnidae.Common.Extensions.StringConvertExtensions.ToDouble ( this string  value,
string  name 
)
static

Converts a string value into a double

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted double value

◆ ToEnum< T >() [1/2]

static T Sphyrnidae.Common.Extensions.StringConvertExtensions.ToEnum< T > ( this string  str)
static

Casts a string to an enum

Template Parameters
TAn enumeration
Parameters
strThe value of the enumeration to check
Returns
The enumeration value
Type Constraints
T :struct 
T :IConvertible 

◆ ToEnum< T >() [2/2]

static T Sphyrnidae.Common.Extensions.StringConvertExtensions.ToEnum< T > ( this string  str,
defaultValue 
)
static

Casts a string to an enum

Template Parameters
TAn enumeration
Parameters
strThe value of the enumeration to check
defaultValueIf can not find a match, this will be returned
Returns
The enumeration value
Type Constraints
T :struct 
T :IConvertible 
T :Enum.TryParse 
T :str 
T :true 
T :out 
T :T 
T :myEnum 
T :defaultValue 
T :myEnum 

◆ ToFloat() [1/2]

static float Sphyrnidae.Common.Extensions.StringConvertExtensions.ToFloat ( this string  value,
float  defaultValue 
)
static

Converts a string value into a float

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted float value (or defaultValue)

◆ ToFloat() [2/2]

static float Sphyrnidae.Common.Extensions.StringConvertExtensions.ToFloat ( this string  value,
string  name 
)
static

Converts a string value into a float

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted double value

◆ ToGuid() [1/2]

static Guid Sphyrnidae.Common.Extensions.StringConvertExtensions.ToGuid ( this string  value,
Guid  defaultValue 
)
static

Converts a string value into a Guid

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted Guid value (or defaultValue)

◆ ToGuid() [2/2]

static Guid Sphyrnidae.Common.Extensions.StringConvertExtensions.ToGuid ( this string  value,
string  name 
)
static

Converts a string value into a Guid

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted Guid value

◆ ToInt() [1/2]

static int Sphyrnidae.Common.Extensions.StringConvertExtensions.ToInt ( this string  value,
int  defaultValue 
)
static

Converts a string value into an integer

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted integer value (or defaultValue)

◆ ToInt() [2/2]

static int Sphyrnidae.Common.Extensions.StringConvertExtensions.ToInt ( this string  value,
string  name 
)
static

Converts a string value into an integer

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted integer value

◆ ToIntParsed() [1/2]

static int Sphyrnidae.Common.Extensions.StringConvertExtensions.ToIntParsed ( this string  value,
int  defaultValue 
)
static

Converts a string value into an integer, using ParseInt function similar to Javascript (eg. 12ab3 = 12)

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted integer value (or defaultValue)

◆ ToIntParsed() [2/2]

static int Sphyrnidae.Common.Extensions.StringConvertExtensions.ToIntParsed ( this string  value,
string  name 
)
static

Converts a string value into an integer, using ParseInt function similar to Javascript (eg. 12ab3 = 12)

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted integer value

◆ ToLong() [1/2]

static long Sphyrnidae.Common.Extensions.StringConvertExtensions.ToLong ( this string  value,
long  defaultValue 
)
static

Converts a string value into a long

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted long value (or defaultValue)

◆ ToLong() [2/2]

static long Sphyrnidae.Common.Extensions.StringConvertExtensions.ToLong ( this string  value,
string  name 
)
static

Converts a string value into a long

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted long value

◆ ToNullableBool() [1/2]

static ? bool Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableBool ( this string  value,
bool?  defaultValue = null 
)
static

Converts a string into a nullable bool

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted true/false (or defaultValue)

◆ ToNullableBool() [2/2]

static ? bool Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableBool ( this string  value,
string  name 
)
static

Converts a string into a nullable bool

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted true/false

◆ ToNullableChar() [1/2]

static ? char Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableChar ( this string  value,
char?  defaultValue = null 
)
static

Converts a string value into a nullable char

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted char value (or defaultValue)

◆ ToNullableChar() [2/2]

static ? char Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableChar ( this string  value,
string  name 
)
static

Converts a string value into a nullable char

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted char value

◆ ToNullableColor() [1/2]

static ? Color Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableColor ( this string  value,
Color?  defaultValue = null 
)
static

Converts a string value into a Color

Parameters
valueThe string to convert
defaultValueIf the value is somehow bad, this will be returned instead
Returns
The converted Color (or defaultValue)

◆ ToNullableColor() [2/2]

static ? Color Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableColor ( this string  value,
string  name 
)
static

Converts a string value into a Color

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error)
Returns
The converted Color

◆ ToNullableDateTime() [1/2]

static ? DateTime Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableDateTime ( this string  value,
DateTime?  defaultValue = null 
)
static

Converts a string value into a nullable datetime

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted datetime value (or defaultValue)

◆ ToNullableDateTime() [2/2]

static ? DateTime Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableDateTime ( this string  value,
string  name 
)
static

Converts a string value into a nullable datetime

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted datetime value

◆ ToNullableDecimal() [1/2]

static ? decimal Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableDecimal ( this string  value,
decimal?  defaultValue = null 
)
static

Converts a string value into a nullable decimal

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted decimal value (or defaultValue)

◆ ToNullableDecimal() [2/2]

static ? decimal Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableDecimal ( this string  value,
string  name 
)
static

Converts a string value into a nullable decimal

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted decimal value

◆ ToNullableDouble() [1/2]

static ? double Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableDouble ( this string  value,
double?  defaultValue = null 
)
static

Converts a string value into a nullable double

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted double value (or defaultValue)

◆ ToNullableDouble() [2/2]

static ? double Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableDouble ( this string  value,
string  name 
)
static

Converts a string value into a nullable double

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted double value

◆ ToNullableFloat() [1/2]

static ? float Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableFloat ( this string  value,
float?  defaultValue = null 
)
static

Converts a string value into a nullable float

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted float value (or defaultValue)

◆ ToNullableFloat() [2/2]

static ? float Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableFloat ( this string  value,
string  name 
)
static

Converts a string value into a nullable float

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted float value

◆ ToNullableGuid() [1/2]

static ? Guid Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableGuid ( this string  value,
Guid?  defaultValue = null 
)
static

Converts a string value into a nullable Guid

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted Guid value (or defaultValue)

◆ ToNullableGuid() [2/2]

static ? Guid Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableGuid ( this string  value,
string  name 
)
static

Converts a string value into a nullable Guid

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted Guid value

◆ ToNullableInt() [1/2]

static ? int Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableInt ( this string  value,
int?  defaultValue = null 
)
static

Converts a string value into a nullable integer

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted integer value (or defaultValue)

◆ ToNullableInt() [2/2]

static ? int Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableInt ( this string  value,
string  name 
)
static

Converts a string value into a nullable integer

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted integer value

◆ ToNullableLong() [1/2]

static ? long Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableLong ( this string  value,
long?  defaultValue = null 
)
static

Converts a string value into a nullable long

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted long value (or defaultValue)

◆ ToNullableLong() [2/2]

static ? long Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableLong ( this string  value,
string  name 
)
static

Converts a string value into a nullable long

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted long value

◆ ToNullableShort() [1/2]

static ? short Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableShort ( this string  value,
short?  defaultValue = null 
)
static

Converts a string value into a nullable short

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted short value (or defaultValue)

◆ ToNullableShort() [2/2]

static ? short Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableShort ( this string  value,
string  name 
)
static

Converts a string value into a nullable short

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted short value

◆ ToNullableULong() [1/2]

static ? ulong Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableULong ( this string  value,
string  name 
)
static

Converts a string value into a nullable ulong

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted ulong value

◆ ToNullableULong() [2/2]

static ? ulong Sphyrnidae.Common.Extensions.StringConvertExtensions.ToNullableULong ( this string  value,
ulong?  defaultValue = null 
)
static

Converts a string value into a nullable ulong

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted ulong value (or defaultValue)

◆ ToShort() [1/2]

static short Sphyrnidae.Common.Extensions.StringConvertExtensions.ToShort ( this string  value,
short  defaultValue 
)
static

Converts a string value into a short

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted short value (or defaultValue)

◆ ToShort() [2/2]

static short Sphyrnidae.Common.Extensions.StringConvertExtensions.ToShort ( this string  value,
string  name 
)
static

Converts a string value into a short

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted short value

◆ ToULong() [1/2]

static ulong Sphyrnidae.Common.Extensions.StringConvertExtensions.ToULong ( this string  value,
string  name 
)
static

Converts a string value into a ulong

Parameters
valueThe string to convert
nameThe name of the thing being converted (in case of error, a nice exception will be thrown)
Returns
The converted ulong value

◆ ToULong() [2/2]

static ulong Sphyrnidae.Common.Extensions.StringConvertExtensions.ToULong ( this string  value,
ulong  defaultValue 
)
static

Converts a string value into a ulong

Parameters
valueThe string to convert
defaultValueIf the 'value' is somehow bad, this will be returned instead
Returns
The converted ulong value (or defaultValue)

The documentation for this class was generated from the following file: