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
typeTypeThe 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
valueTThe value to check for default value.
Returns
- bool
True if the value is the default value, false otherwise.
Type Parameters
TThe 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
toTypeTypeThe target generic type.
fromTypeTypeThe source type.
genericArgumentsType[]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
typeTypeThe type to check.
Returns
- bool
True if the type is nullable, false otherwise.