Table of Contents

Class TypeControlExtensions

Namespace
HeroKit.Types
Assembly
HeroKit.dll

Provides extension methods for Type values.

public static class TypeControlExtensions
Inheritance
TypeControlExtensions
Inherited Members

Methods

GetUnderlyingType(Type)

Gets the underlying non-nullable type of a nullable type (if applicable). If the input type is not nullable, the same type is returned.

public static Type GetUnderlyingType(this Type type)

Parameters

type Type

The type to examine.

Returns

Type

The underlying non-nullable type or the same type if not nullable.

IsDefaultValue<T>(T)

Checks if the provided value is the default value for its type.

public static bool IsDefaultValue<T>(this T value)

Parameters

value T

The value to check for default value.

Returns

bool

True if the value is the default value, false otherwise.

Type Parameters

T

The type of the value to check.

IsGenericAssignableFrom(Type, Type, out Type[]?)

Checks if a generic type is assignable from another type and provides generic arguments if applicable.

public static bool IsGenericAssignableFrom(this Type toType, Type fromType, out Type[]? genericArguments)

Parameters

toType Type

The target generic type.

fromType Type

The source type.

genericArguments Type[]

The generic arguments if assignment is possible, otherwise null.

Returns

bool

True if assignment is possible, false otherwise.

IsNullable(Type)

Checks if a type is a Nullable type (e.g., int?, double?).

public static bool IsNullable(this Type type)

Parameters

type Type

The type to check.

Returns

bool

True if the type is nullable, false otherwise.