Search Results for

    Show / Hide Table of Contents

    Class TypeConverter

    Utility class for converting strings to various types.

    Inheritance
    object
    TypeConverter
    Namespace: AS2
    Assembly: .dll
    Syntax
    public static class TypeConverter

    Fields

    | Edit this page View Source

    floatsUseComma

    Declaration
    private static bool floatsUseComma
    Field Value
    Type Description
    bool

    Methods

    | Edit this page View Source

    ConvertStringInStringThatCanBeConvertedToFloat(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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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 type, if possible, otherwise the original input string text.

    | Edit this page View Source

    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

    true if and only if the local settings use the comma ',' instead of the period '.' as decimal point.

    • Edit this page
    • View Source
    In this article
    Back to top AmoebotSim 2.0 Documentation v1.11
    Copyright © 2025 AmoebotSim 2.0 Authors
    Generated by DocFX