Skip to main content

TypeUtilities Class

Definition​

Assembly:Avalonia.Base
Package:Avalonia

Provides utilities for working with types at runtime.

public class TypeUtilities

Inheritance: object -> TypeUtilities

Methods​

NameDescription
AcceptsNull (2 overloads)No summary available.
CanCastNo summary available.
ConvertImplicitNo summary available.
ConvertImplicitOrDefaultConvert a value to a type using the implicit conversions allowed by the C# language or return the default for the type if the value could not be converted.
ConvertOrDefaultConvert a value to a type by any means possible, returning the default for that type if the value could not be converted.
DefaultGets the default value for the specified type.
IsNumericDetermines if a type is numeric. Nullable numeric types are considered numeric.
TryConvertNo summary available.
TryConvertImplicitNo summary available.

AcceptsNull overloads​

AcceptsNull Method​

public bool AcceptsNull<T>()
Type Parameters​

T

Returns​

bool

AcceptsNull Method​

Returns a value indicating whether null can be assigned to the specified type.

public bool AcceptsNull(Type type)
Parameters​

type Type

The type.

Returns​

bool

True if the type accepts null values; otherwise false.

CanCast Method​

public bool CanCast<T>(object value)

Parameters​

value object

Type Parameters​

T

Returns​

bool

ConvertImplicit Method​

public T ConvertImplicit<T>(object value)

Parameters​

value object

Type Parameters​

T

Returns​

T

ConvertImplicitOrDefault Method​

Convert a value to a type using the implicit conversions allowed by the C# language or return the default for the type if the value could not be converted.

public object ConvertImplicitOrDefault(object value, Type type)

Parameters​

value object

The value to convert.

type Type

The type to convert to.

Returns​

object

A value of type.

ConvertOrDefault Method​

Convert a value to a type by any means possible, returning the default for that type if the value could not be converted.

public object ConvertOrDefault(object value, Type type, System.Globalization.CultureInfo culture)

Parameters​

value object

The value to convert.

type Type

The type to convert to.

culture System.Globalization.CultureInfo

The culture to use.

Returns​

object

A value of type.

Default Method​

Gets the default value for the specified type.

public object Default(Type type)

Parameters​

type Type

The type.

Returns​

object

The default value.

IsNumeric Method​

Determines if a type is numeric. Nullable numeric types are considered numeric.

public bool IsNumeric(Type type)

Parameters​

type Type

Returns​

bool

True if the type is numeric; otherwise false.

Remarks​

Boolean is not considered numeric.

TryConvert Method​

public bool TryConvert(Type to, object value, System.Globalization.CultureInfo culture, object& result)

Parameters​

to Type

value object

culture System.Globalization.CultureInfo

result object&

Returns​

bool

TryConvertImplicit Method​

public bool TryConvertImplicit(Type to, object value, object& result)

Parameters​

to Type

value object

result object&

Returns​

bool