Table of Contents

Method FromString

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

FromString(string, CultureInfo?)

Converts a string representation of a coordinate value, including an optional unit, into a float object.

public static float FromString(string s, CultureInfo? cultureInfo)

Parameters

s string

The string to parse. The string should be in the format "[value][unit]", where [value] is a numeric value and [unit] is an optional unit specifier (e.g., "px", "in"). If no unit is specified, the value is interpreted as pixels. The special value "auto" is interpreted as NaN.

cultureInfo CultureInfo

The CultureInfo used to interpret the numeric value in the string.

Returns

float

A float object representing the parsed value. If the string specifies "auto", NaN is returned.

Remarks

This method is culture-sensitive for parsing the numeric value but uses a fixed, culture-invariant set of unit strings. Supported unit strings include "px" (pixels) and other predefined units. If the string does not end with a recognized unit, it is assumed to represent pixels.

Exceptions

FormatException

Thrown if the string cannot be parsed into a valid coordinate value.