-
Notifications
You must be signed in to change notification settings - Fork 0
Type Extensions
Andrzej Kebab edited this page Jan 21, 2024
·
3 revisions
This utility library provides extension methods for the Type class to simplify common operations related to types.
Gets the default value of the specified type.
using UtilityLibrary.Core;
Type myType = typeof(int);
object defaultValue = myType.DefaultValue();-
type(Type): The type to get the default value for.
- object: The default value for the specified type. For value types, this is usually the equivalent of 'new T()', and for reference types, this is null.
Determines whether the specified type is a nullable type.
using UtilityLibrary.Core;
Type myType = typeof(int);
bool isNullable = myType.IsNullableType();-
type(Type): The type to check.
- bool:
Trueif the specified type is a nullable type; otherwise,False.
Checks if the specified type is a numeric type.
using UtilityLibrary.Core;
Type myType = typeof(int);
bool isNumeric = myType.IsNumericType();-
type(Type): The type to check.
- bool:
Trueif the type is numeric; otherwise,False.