Extension methods for string.
More...
|
| static T | To< T > (this string text, T defaultValue=default, bool exception=false) |
| | Syntactic sugar to convert a string to the specified type. More...
|
| |
| static object | To (this string text, Type type, object defaultValue=null, bool exception=false) |
| | Syntactic sugar to convert a string to the specified type. More...
|
| |
| static float[] | ExtractFloats (this string text) |
| | Extract all the float from specified string. More...
|
| |
| static byte[] | ExtractBytes (this string text) |
| | Extract all the byte from specified string. More...
|
| |
Extension methods for string.
| static T To< T > |
( |
this string |
text, |
|
|
T |
defaultValue = default, |
|
|
bool |
exception = false |
|
) |
| |
|
static |
Syntactic sugar to convert a string to the specified type.
Use methods below for generic conversion:
TypeConverter.ConvertFromString(), you may make custom converter to support in need.
- Static
Parse() method declared by the value type.
JsonUtility.FromJson() as fallback.
- Template Parameters
-
- Parameters
-
| text | Text. |
| defaultValue | The default value. |
| exception | If convert failed, throw an exception or return the default value. |
- Returns
- The value.
| static object To |
( |
this string |
text, |
|
|
Type |
type, |
|
|
object |
defaultValue = null, |
|
|
bool |
exception = false |
|
) |
| |
|
static |
Syntactic sugar to convert a string to the specified type.
Use methods below for generic conversion:
TypeConverter.ConvertFromString(), you may make custom converter to support in need.
- Static
Parse() method declared by the value type.
JsonUtility.FromJson() as fallback.
- Parameters
-
| text | Text. |
| type | The value type. |
| defaultValue | The default value. |
| exception | If convert failed, throw an exception or return the default value. |
- Returns
- The value.
| static float [] ExtractFloats |
( |
this string |
text | ) |
|
|
static |
Extract all the float from specified string.
E.g., input "12.3x, -4.5e2)&1.6e-1#N.047" to result [12.3, -450, 0.16, 47].
- Parameters
-
- Returns
- The floats.
| static byte [] ExtractBytes |
( |
this string |
text | ) |
|
|
static |
Extract all the byte from specified string.
Any invalid char within is removed directly, and parse the remain char sequence. E.g., input "{05, Ad}+/720fR*bYTes.C" to result [05-AD-72-0F-BE].
- Parameters
-
- Returns
- The bytes.