Table of Contents

Method TryParseValue

Namespace
Terminal.Gui.ViewBase
Assembly
Terminal.Gui.dll

TryParseValue<TValue>(string, out TValue?)

Attempts to parse input into a value of type TValue.

[UnconditionalSuppressMessage("Trimming", "IL2090:'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to target method.", Justification = "Reflective lookup of static TryParse(string, IFormatProvider?, out T) is intentional. Callers using AOT/trimming with custom IParsable types should preserve the TryParse method via DynamicDependency or equivalent.")]
public static bool TryParseValue<TValue>(string input, out TValue? parsed)

Parameters

input string

The string representation to parse.

parsed TValue

When this method returns true, contains the parsed value; otherwise default.

Returns

bool

true if input was parsed successfully; otherwise false.

Type Parameters

TValue

The target value type. May be a reference type, value type, or Nullable<T>.

Remarks

Supported types:

  • string (assigned directly).
  • Any type implementing IParsable<TSelf> via reflection on the static TryParse(string, IFormatProvider?, out T) method.
  • Nullable<T> wrappers around any of the above.
  • Enum types (case-insensitive).