Class StringValueConversion
Provides extension methods for converting string values to different scalar types
Inheritance
System.Object
StringValueConversion
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Azos.dll
Syntax
public static class StringValueConversion
Fields
ARRAY_SPLIT_CHARS
Declaration
public static readonly char[] ARRAY_SPLIT_CHARS
Field Value
Type |
Description |
System.Char[] |
|
Methods
AsBool(String, Boolean)
Declaration
public static bool AsBool(this string val, bool dflt = false)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Boolean |
dflt |
|
Returns
Type |
Description |
System.Boolean |
|
AsByte(String, Byte)
Declaration
public static byte AsByte(this string val, byte dflt = 0)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Byte |
dflt |
|
Returns
Type |
Description |
System.Byte |
|
AsByteArray(String, Byte[])
Declaration
public static byte[] AsByteArray(this string val, byte[] dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Byte[] |
dflt |
|
Returns
Type |
Description |
System.Byte[] |
|
AsDateTime(String, DateTime)
Declaration
public static DateTime AsDateTime(this string val, DateTime dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.DateTime |
dflt |
|
Returns
Type |
Description |
System.DateTime |
|
Declaration
public static DateTime AsDateTimeFormat(this string val, DateTime dflt, string fmt, DateTimeStyles fmtStyles = DateTimeStyles.None)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.DateTime |
dflt |
|
System.String |
fmt |
|
System.Globalization.DateTimeStyles |
fmtStyles |
|
Returns
Type |
Description |
System.DateTime |
|
AsDateTimeOrThrow(String)
Declaration
public static DateTime AsDateTimeOrThrow(this string val)
Parameters
Type |
Name |
Description |
System.String |
val |
|
Returns
Type |
Description |
System.DateTime |
|
AsDecimal(String, Decimal)
Declaration
public static decimal AsDecimal(this string val, decimal dflt = 0M)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Decimal |
dflt |
|
Returns
Type |
Description |
System.Decimal |
|
AsDecimalArray(String, Decimal[])
Declaration
public static decimal[] AsDecimalArray(this string val, decimal[] dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Decimal[] |
dflt |
|
Returns
Type |
Description |
System.Decimal[] |
|
AsDouble(String, Double)
Declaration
public static double AsDouble(this string val, double dflt = 0)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Double |
dflt |
|
Returns
Type |
Description |
System.Double |
|
AsDoubleArray(String, Double[])
Declaration
public static double[] AsDoubleArray(this string val, double[] dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Double[] |
dflt |
|
Returns
Type |
Description |
System.Double[] |
|
AsEnum<TEnum>(String, TEnum)
Declaration
public static TEnum AsEnum<TEnum>(this string val, TEnum dflt = default(TEnum))
where TEnum : struct
Parameters
Type |
Name |
Description |
System.String |
val |
|
TEnum |
dflt |
|
Returns
Type Parameters
AsFloat(String, Single)
Declaration
public static float AsFloat(this string val, float dflt = 0F)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Single |
dflt |
|
Returns
Type |
Description |
System.Single |
|
AsFloatArray(String, Single[])
Declaration
public static float[] AsFloatArray(this string val, float[] dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Single[] |
dflt |
|
Returns
Type |
Description |
System.Single[] |
|
AsGDID(String, Nullable<GDID>)
Declaration
public static GDID AsGDID(this string val, GDID? dflt = default(GDID? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<GDID> |
dflt |
|
Returns
AsGDIDSymbol(String, Nullable<GDIDSymbol>)
Declaration
public static GDIDSymbol AsGDIDSymbol(this string val, GDIDSymbol? dflt = default(GDIDSymbol? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<GDIDSymbol> |
dflt |
|
Returns
AsGUID(String, Guid)
Declaration
public static Guid AsGUID(this string val, Guid dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Guid |
dflt |
|
Returns
Type |
Description |
System.Guid |
|
AsInt(String, Int32)
Declaration
public static int AsInt(this string val, int dflt = 0)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Int32 |
dflt |
|
Returns
Type |
Description |
System.Int32 |
|
AsIntArray(String, Int32[])
Declaration
public static int[] AsIntArray(this string val, int[] dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Int32[] |
dflt |
|
Returns
Type |
Description |
System.Int32[] |
|
AsLong(String, Int64)
Declaration
public static long AsLong(this string val, long dflt = 0L)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Int64 |
dflt |
|
Returns
Type |
Description |
System.Int64 |
|
AsLongArray(String, Int64[])
Declaration
public static long[] AsLongArray(this string val, long[] dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Int64[] |
dflt |
|
Returns
Type |
Description |
System.Int64[] |
|
AsNullableBool(String, Nullable<Boolean>)
Declaration
public static bool? AsNullableBool(this string val, bool? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Boolean> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Boolean> |
|
AsNullableByte(String, Nullable<Byte>)
Declaration
public static byte? AsNullableByte(this string val, byte? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Byte> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Byte> |
|
AsNullableDateTime(String, Nullable<DateTime>)
Declaration
public static DateTime? AsNullableDateTime(this string val, DateTime? dflt = default(DateTime? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.DateTime> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.DateTime> |
|
AsNullableDecimal(String, Nullable<Decimal>)
Declaration
public static decimal? AsNullableDecimal(this string val, decimal? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Decimal> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Decimal> |
|
AsNullableDouble(String, Nullable<Double>)
Declaration
public static double? AsNullableDouble(this string val, double? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Double> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Double> |
|
AsNullableEnum<TEnum>(String, Nullable<TEnum>)
Declaration
public static TEnum? AsNullableEnum<TEnum>(this string val, TEnum? dflt = default(TEnum? ))
where TEnum : struct
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<TEnum> |
dflt |
|
Returns
Type |
Description |
System.Nullable<TEnum> |
|
Type Parameters
AsNullableFloat(String, Nullable<Single>)
Declaration
public static float? AsNullableFloat(this string val, float? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Single> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Single> |
|
AsNullableGDID(String, Nullable<GDID>)
Declaration
public static GDID? AsNullableGDID(this string val, GDID? dflt = default(GDID? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<GDID> |
dflt |
|
Returns
Type |
Description |
System.Nullable<GDID> |
|
AsNullableGDIDSymbol(String, Nullable<GDIDSymbol>)
Declaration
public static GDIDSymbol? AsNullableGDIDSymbol(this string val, GDIDSymbol? dflt = default(GDIDSymbol? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<GDIDSymbol> |
dflt |
|
Returns
AsNullableGUID(String, Nullable<Guid>)
Declaration
public static Guid? AsNullableGUID(this string val, Guid? dflt = default(Guid? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Guid> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Guid> |
|
AsNullableInt(String, Nullable<Int32>)
Declaration
public static int? AsNullableInt(this string val, int? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Int32> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Int32> |
|
AsNullableLong(String, Nullable<Int64>)
Declaration
public static long? AsNullableLong(this string val, long? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Int64> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Int64> |
|
AsNullableSByte(String, Nullable<SByte>)
Declaration
public static sbyte? AsNullableSByte(this string val, sbyte? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.SByte> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.SByte> |
|
AsNullableShort(String, Nullable<Int16>)
Declaration
public static short? AsNullableShort(this string val, short? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.Int16> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.Int16> |
|
AsNullableTimeSpan(String, Nullable<TimeSpan>)
Declaration
public static TimeSpan? AsNullableTimeSpan(this string val, TimeSpan? dflt = default(TimeSpan? ))
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.TimeSpan> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.TimeSpan> |
|
AsNullableUInt(String, Nullable<UInt32>)
Declaration
public static uint? AsNullableUInt(this string val, uint? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.UInt32> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.UInt32> |
|
AsNullableULong(String, Nullable<UInt64>)
Declaration
public static ulong? AsNullableULong(this string val, ulong? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.UInt64> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.UInt64> |
|
AsNullableUShort(String, Nullable<UInt16>)
Declaration
public static ushort? AsNullableUShort(this string val, ushort? dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Nullable<System.UInt16> |
dflt |
|
Returns
Type |
Description |
System.Nullable<System.UInt16> |
|
AsSByte(String, SByte)
Declaration
public static sbyte AsSByte(this string val, sbyte dflt = 0)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.SByte |
dflt |
|
Returns
Type |
Description |
System.SByte |
|
AsShort(String, Int16)
Declaration
public static short AsShort(this string val, short dflt = 0)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Int16 |
dflt |
|
Returns
Type |
Description |
System.Int16 |
|
AsString(String, String)
Used by env var macros evaluator do not remove
Declaration
public static string AsString(this string val, string dflt = "")
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.String |
dflt |
|
Returns
Type |
Description |
System.String |
|
AsStringWhenNullOrEmpty(String, String)
Used by env var macros evaluator do not remove
Declaration
public static string AsStringWhenNullOrEmpty(this string val, string dflt = "")
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.String |
dflt |
|
Returns
Type |
Description |
System.String |
|
AsTimeSpan(String, TimeSpan)
Declaration
public static TimeSpan AsTimeSpan(this string val, TimeSpan dflt)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.TimeSpan |
dflt |
|
Returns
Type |
Description |
System.TimeSpan |
|
AsTimeSpanOrThrow(String)
Declaration
public static TimeSpan AsTimeSpanOrThrow(this string val)
Parameters
Type |
Name |
Description |
System.String |
val |
|
Returns
Type |
Description |
System.TimeSpan |
|
AsType(String, Type, Boolean)
Tries to get a string value as specified type.
When 'strict=false', tries to do some inference like return "true" for numbers that dont equal to zero etc.
When 'strict=true' throws an exception if deterministic conversion is not possible
Declaration
public static object AsType(this string val, Type tp, bool strict = true)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Type |
tp |
|
System.Boolean |
strict |
|
Returns
Type |
Description |
System.Object |
|
AsUInt(String, UInt32)
Declaration
public static uint AsUInt(this string val, uint dflt = 0U)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.UInt32 |
dflt |
|
Returns
Type |
Description |
System.UInt32 |
|
AsULong(String, UInt64)
Declaration
public static ulong AsULong(this string val, ulong dflt = 0UL)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.UInt64 |
dflt |
|
Returns
Type |
Description |
System.UInt64 |
|
AsUri(String, Uri)
Declaration
public static Uri AsUri(this string val, Uri dflt = null)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.Uri |
dflt |
|
Returns
Type |
Description |
System.Uri |
|
AsUShort(String, UInt16)
Declaration
public static ushort AsUShort(this string val, ushort dflt = 0)
Parameters
Type |
Name |
Description |
System.String |
val |
|
System.UInt16 |
dflt |
|
Returns
Type |
Description |
System.UInt16 |
|