This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -801,6 +801,39 @@ public static long ToInt64(this string text, long defaultValue)
801801 return Int64 . TryParse ( text , out ret ) ? ret : defaultValue ;
802802 }
803803
804+ public static float ToFloat ( this string text )
805+ {
806+ return text == null ? default ( float ) : float . Parse ( text ) ;
807+ }
808+
809+ public static float ToFloat ( this string text , float defaultValue )
810+ {
811+ float ret ;
812+ return float . TryParse ( text , out ret ) ? ret : defaultValue ;
813+ }
814+
815+ public static double ToDouble ( this string text )
816+ {
817+ return text == null ? default ( double ) : double . Parse ( text ) ;
818+ }
819+
820+ public static double ToDouble ( this string text , double defaultValue )
821+ {
822+ double ret ;
823+ return double . TryParse ( text , out ret ) ? ret : defaultValue ;
824+ }
825+
826+ public static decimal ToDecimal ( this string text )
827+ {
828+ return text == null ? default ( decimal ) : decimal . Parse ( text ) ;
829+ }
830+
831+ public static decimal ToDecimal ( this string text , decimal defaultValue )
832+ {
833+ decimal ret ;
834+ return decimal . TryParse ( text , out ret ) ? ret : defaultValue ;
835+ }
836+
804837 public static bool Glob ( this string value , string pattern )
805838 {
806839 int pos ;
You can’t perform that action at this time.
0 commit comments