Class TypeConverter
Utility class for converting strings to various types.
Inheritance
Namespace: AS2
Assembly: .dll
Syntax
public static class TypeConverter
Fields
| Edit this page View SourcefloatsUseComma
Declaration
private static bool floatsUseComma
Field Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceConvertStringInStringThatCanBeConvertedToFloat(string)
We might want to deliver strings that are easily converted to floats by float.Parse(..) to other classes. This is the method for that.
Declaration
public static string ConvertStringInStringThatCanBeConvertedToFloat(string text)
Parameters
Type | Name | Description |
---|---|---|
string | text | Text to convert to convertible text. |
Returns
Type | Description |
---|---|
string | A modified string that can be parsed into a float value easily. |
ConvertStringToFloat(string)
Depending on the local settings, there are multiple possibilities how to convert a string to float (, or . can be used). Here we try out all possible ways to convert until we find the right one. :)
Declaration
public static TypeConverter.ConversionResult ConvertStringToFloat(string text)
Parameters
Type | Name | Description |
---|---|---|
string | text | Text to convert to float. |
Returns
Type | Description |
---|---|
TypeConverter.ConversionResult | A TypeConverter.ConversionResult that represents the outcome of the conversion attempt. |
ConvertStringToObjectOfType(Type, string)
Converts a string to an object of the given type. Supported types are bool, int, float, string and enum.
Declaration
public static object ConvertStringToObjectOfType(Type type, string text)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The desired type. |
string | text | The string that should be converted. |
Returns
Type | Description |
---|---|
object | An object of the specified |
FloatsUseCommaInsteadOfPoint()
Detects if the local settings use a comma for the conversion of float to string and string to float.
Declaration
public static bool FloatsUseCommaInsteadOfPoint()
Returns
Type | Description |
---|---|
bool |
|