示例#1
0
 /// <summary>
 /// Converts the string value to a boolean value.
 /// </summary>
 /// <param name="_bool">The string to convert.</param>
 /// <returns> For strings beginning with y or t (yes, true, TRUE, YES, etc) or just the value 1, true is returned. All other strings return false.</returns>
 public static bool ToBool(this string _string)
 {
     return(StringConverters._ToBool(_string, false, false));
 }
示例#2
0
 /// <summary>
 /// Converts the string value to a boolean value.
 /// </summary>
 /// <param name="_string">The string to convert.</param>
 /// <param name="defaultValue">Default value to return if the conversion fails.</param>
 /// <returns> For strings beginning with y or t (yes, true, TRUE, YES, etc) or just the value 1, true is returned. All other strings return false.</returns>
 public static bool ToBool(this string _string, bool defaultValue)
 {
     return(StringConverters._ToBool(_string, true, defaultValue));
 }
示例#3
0
 /// <summary>
 /// Converts the string to an enumeration value of type T, ignoring case.
 /// </summary>
 /// <typeparam name="T">Enum</typeparam>
 /// <param name="_string">String value to convert.</param>
 /// <returns>The numeration value represneted by the string, ignoring case.</returns>
 public static T ToEnum <T>(this string _string) where T : struct, IConvertible
 {
     return(StringConverters._ToEnum <T>(_string, false, default(T)));
 }
示例#4
0
 /// <summary>
 /// Converts the string to an enumeration value of type T, ignoring case.
 /// </summary>
 /// <typeparam name="T">Enum</typeparam>
 /// <param name="_string">String value to convert.</param>
 /// <param name="defaultValue">The default value if the conversion fails.</param>
 /// <returns>The numeration value represneted by the string, ignoring case.</returns>
 public static T ToEnum <T>(this string _string, T defaultValue) where T : struct, IConvertible
 {
     return(StringConverters._ToEnum <T>(_string, true, defaultValue));
 }
示例#5
0
 /// <summary>
 /// Returns the double representation of the string. Blank strings and null return 0.
 /// </summary>
 /// <param name="_string">The string to convert.</param>
 /// <param name="defaultValue">The default value to return if the conversion fails.</param>
 /// <returns>The double value of the string.</returns>
 public static double ToDouble(this string _string, double defaultValue)
 {
     return(StringConverters._ToDouble(_string, true, defaultValue));
 }
示例#6
0
 /// <summary>
 /// Returns the double representation of the string. Blank strings and null return 0.
 /// </summary>
 /// <param name="_string">The string to convert.</param>
 /// <returns>The double value of the string.</returns>
 public static double ToDouble(this string _string)
 {
     return(StringConverters._ToDouble(_string, false, 0));
 }
示例#7
0
 /// <summary>
 /// Returns the integer representation of the string. Blank strings and null return 0.
 /// </summary>
 /// <param name="_string">The string to convert.</param>
 ///<param name="defaultValue">The default value to return if the conversion fails.</param>
 /// <returns>The integer value of the string.</returns>
 public static int ToInt(this string _string, int defaultValue)
 {
     return(StringConverters._ToInt(_string, true, defaultValue));
 }
示例#8
0
 /// <summary>
 /// Returns the integer representation of the string. Blank strings and null return 0.
 /// </summary>
 /// <param name="_string">The string to convert.</param>
 /// <returns>The integer value of the string.</returns>
 public static int ToInt(this string _string)
 {
     return(StringConverters._ToInt(_string, false, 0));
 }
示例#9
0
 /// <summary>
 /// Converts the string to a DateTime value.
 /// </summary>
 /// <param name="_string">String to convert.</param>
 /// <param name="defaultValue">Default value to return if the conversion fails.</param>
 /// <returns>The converted DateTime.</returns>
 public static DateTime ToDateTime(this string _string, DateTime defaultValue)
 {
     return(StringConverters._ToDateTime(_string, true, Conventions.NullDate));
 }