Unosquare
    Show / Hide Table of Contents

    Class FromString

    Provides a standard way to convert strings to different types.

    Inheritance
    Object
    FromString
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Swan
    Syntax
    public static class FromString

    Methods

    CanConvertTo(Type)

    Determines whether a string can be converted to the specified type.

    Declaration
    public static bool CanConvertTo(Type type)
    Parameters
    Type Name Description
    Type type

    The type resulting from the conversion.

    Returns
    Type Description
    Boolean

    true if the conversion is possible; otherwise, false.

    CanConvertTo<TResult>()

    Determines whether a string can be converted to the specified type.

    Declaration
    public static bool CanConvertTo<TResult>()
    Returns
    Type Description
    Boolean

    true if the conversion is possible; otherwise, false.

    Type Parameters
    Name Description
    TResult

    The type resulting from the conversion.

    ConvertExpressionTo(Type, Expression)

    Converts a expression, if the type can be converted to string, to a new expression including the conversion to string.

    Declaration
    public static Expression? ConvertExpressionTo(Type type, Expression str)
    Parameters
    Type Name Description
    Type type

    The type.

    Expression str

    The string.

    Returns
    Type Description
    Nullable<Expression>

    A new expression where the previous expression is converted to string.

    ConvertTo(Type, String)

    Converts a string to the specified type.

    Declaration
    public static object ConvertTo(Type type, string str)
    Parameters
    Type Name Description
    Type type

    The type resulting from the conversion.

    String str

    The string to convert.

    Returns
    Type Description
    Object

    An instance of type.

    Exceptions
    Type Condition
    StringConversionException

    The conversion was not successful.

    ConvertTo(Type, String[])

    Converts an array of strings to an array of the specified type.

    Declaration
    public static object ConvertTo(Type type, string[] strings)
    Parameters
    Type Name Description
    Type type

    The type resulting from the conversion of each element of strings.

    String[] strings

    The array to convert.

    Returns
    Type Description
    Object

    An array of type.

    Exceptions
    Type Condition
    StringConversionException

    The conversion of at least one of the elements of stringswas not successful.

    ConvertTo<TResult>(String)

    Converts a string to the specified type.

    Declaration
    public static TResult ConvertTo<TResult>(string str)
    Parameters
    Type Name Description
    String str

    The string to convert.

    Returns
    Type Description
    TResult

    An instance of TResult.

    Type Parameters
    Name Description
    TResult

    The type resulting from the conversion.

    Exceptions
    Type Condition
    StringConversionException

    The conversion was not successful.

    ConvertTo<TResult>(String[])

    Converts an array of strings to an array of the specified type.

    Declaration
    public static TResult[] ConvertTo<TResult>(string[] strings)
    Parameters
    Type Name Description
    String[] strings

    The array to convert.

    Returns
    Type Description
    TResult[]

    An array of TResult.

    Type Parameters
    Name Description
    TResult

    The type resulting from the conversion of each element of strings.

    Exceptions
    Type Condition
    StringConversionException

    The conversion of at least one of the elements of stringswas not successful.

    TryConvertTo(Type, String, out Object)

    Attempts to convert a string to the specified type.

    Declaration
    public static bool TryConvertTo(Type type, string str, out object result)
    Parameters
    Type Name Description
    Type type

    The type resulting from the conversion.

    String str

    The string to convert.

    Object result

    When this method returns true, the result of the conversion. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the conversion is successful; otherwise, false.

    TryConvertTo(Type, String[], out Object)

    Attempts to convert an array of strings to an array of the specified type.

    Declaration
    public static bool TryConvertTo(Type type, string[] strings, out object result)
    Parameters
    Type Name Description
    Type type

    The type resulting from the conversion of each element of strings.

    String[] strings

    The array to convert.

    Object result

    When this method returns true, the result of the conversion. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the conversion is successful; otherwise, false.

    TryConvertTo<TResult>(String, out TResult)

    Attempts to convert a string to the specified type.

    Declaration
    public static bool TryConvertTo<TResult>(string str, out TResult result)
    Parameters
    Type Name Description
    String str

    The string to convert.

    TResult result

    When this method returns true, the result of the conversion. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the conversion is successful; otherwise, false.

    Type Parameters
    Name Description
    TResult

    The type resulting from the conversion.

    TryConvertTo<TResult>(String[], out TResult[])

    Attempts to convert an array of strings to an array of the specified type.

    Declaration
    public static bool TryConvertTo<TResult>(string[] strings, out TResult[] result)
    Parameters
    Type Name Description
    String[] strings

    The array to convert.

    TResult[] result

    When this method returns true, the result of the conversion. This parameter is passed uninitialized.

    Returns
    Type Description
    Boolean

    true if the conversion is successful; otherwise, false.

    Type Parameters
    Name Description
    TResult

    The type resulting from the conversion of each element of strings.

    Comments

    Back to top Copyright © 2017-2019 Unosquare