@@ -28,60 +28,6 @@ namespace JCSUnity
2828 /// </summary>
2929 public static class JCS_Util
3030 {
31- #region Parse
32-
33- /// <summary>
34- /// Is the string the valid number to parse.
35- /// </summary>
36- /// <param name="str"></param>
37- /// <returns></returns>
38- public static bool IsNumberString ( string str )
39- {
40- double test ;
41- return ( double . TryParse ( str , out test ) ) ;
42- }
43-
44- /// <summary>
45- /// Parse `str` to integer, return `defaultValue` if failed.
46- /// </summary>
47- public static int Parse ( string str , int defaultValue )
48- {
49- int result ;
50-
51- if ( int . TryParse ( str , out result ) )
52- return int . Parse ( str ) ;
53-
54- return defaultValue ;
55- }
56-
57- /// <summary>
58- /// Parse `str` to float, return `defaultValue` if failed.
59- /// </summary>
60- public static float Parse ( string str , float defaultValue )
61- {
62- float result ;
63-
64- if ( float . TryParse ( str , out result ) )
65- return float . Parse ( str ) ;
66-
67- return defaultValue ;
68- }
69-
70- /// <summary>
71- /// Parse `str` to boolean, return `defaultValue` if failed.
72- /// </summary>
73- public static bool Parse ( string str , bool defaultValue )
74- {
75- bool result ;
76-
77- if ( bool . TryParse ( str , out result ) )
78- return bool . Parse ( str ) ;
79-
80- return defaultValue ;
81- }
82-
83- #endregion
84-
8531 #region Number
8632
8733 /// <summary>
@@ -503,6 +449,60 @@ public static List<T> RemoveEmptySlotIncludeMissing<T>(List<T> inList)
503449
504450 #endregion
505451
452+ #region Parse
453+
454+ /// <summary>
455+ /// Is the string the valid number to parse.
456+ /// </summary>
457+ /// <param name="str"></param>
458+ /// <returns></returns>
459+ public static bool IsNumberString ( string str )
460+ {
461+ double test ;
462+ return ( double . TryParse ( str , out test ) ) ;
463+ }
464+
465+ /// <summary>
466+ /// Parse `str` to integer, return `defaultValue` if failed.
467+ /// </summary>
468+ public static int Parse ( string str , int defaultValue )
469+ {
470+ int result ;
471+
472+ if ( int . TryParse ( str , out result ) )
473+ return int . Parse ( str ) ;
474+
475+ return defaultValue ;
476+ }
477+
478+ /// <summary>
479+ /// Parse `str` to float, return `defaultValue` if failed.
480+ /// </summary>
481+ public static float Parse ( string str , float defaultValue )
482+ {
483+ float result ;
484+
485+ if ( float . TryParse ( str , out result ) )
486+ return float . Parse ( str ) ;
487+
488+ return defaultValue ;
489+ }
490+
491+ /// <summary>
492+ /// Parse `str` to boolean, return `defaultValue` if failed.
493+ /// </summary>
494+ public static bool Parse ( string str , bool defaultValue )
495+ {
496+ bool result ;
497+
498+ if ( bool . TryParse ( str , out result ) )
499+ return bool . Parse ( str ) ;
500+
501+ return defaultValue ;
502+ }
503+
504+ #endregion
505+
506506 #region JSON
507507
508508 /// <summary>
0 commit comments