Class Intrinsics
Represents highly optimized runtime intrinsic methods.
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public static class Intrinsics : object
Methods
| Improve this Doc View SourceBitcast<T, TResult>(T, out TResult)
Obtain a value of type TResult by
reinterpreting the object representation of T.
Declaration
public static void Bitcast<T, TResult>(in T input, out TResult output)
where T : struct where TResult : struct
Parameters
| Type | Name | Description |
|---|---|---|
| T | input | A value to convert. |
| TResult | output | Conversion result. |
Type Parameters
| Name | Description |
|---|---|
| T | The value type to be converted. |
| TResult | The type of output struct. |
Remarks
Every bit in the value representation of the returned TResult object
is equal to the corresponding bit in the object representation of T.
The values of padding bits in the returned TResult object are unspecified.
The method takes into account size of T and TResult types
and able to provide conversion between types of different size. However, the result may very between
CPU architectures if size of types is different.
DefaultOf<T>()
Returns default value of the given type.
Declaration
public static T DefaultOf<T>()
Returns
| Type | Description |
|---|---|
| T | The default value of type |
Type Parameters
| Name | Description |
|---|---|
| T | The type for which default value should be obtained. |
Remarks
This method helps to avoid generation of temporary variables
necessary for default keyword implementation.
HasFlag<T>(T, T)
Determines whether one or more bit fields are set in the given value.
Declaration
public static bool HasFlag<T>(T value, T flag)
where T : struct, Enum
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to check. |
| T | flag | An enumeration value. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the bit field or bit fields that are set in |
Type Parameters
| Name | Description |
|---|---|
| T |
IsDefault<T>(T)
Indicates that specified value type is the default value.
Declaration
public static bool IsDefault<T>(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | Value to check. |
Returns
| Type | Description |
|---|---|
| Boolean | true, if value is default value; otherwise, false. |
Type Parameters
| Name | Description |
|---|---|
| T |
IsNullable<T>()
Provides the fast way to check whether the specified type accepts null value as valid value.
Declaration
public static bool IsNullable<T>()
Returns
| Type | Description |
|---|---|
| Boolean | true if |
Type Parameters
| Name | Description |
|---|---|
| T | The type to check. |
Remarks
This method always returns true for all reference types and
TypeOf<T>()
Returns the runtime handle associated with type T.
Declaration
public static RuntimeTypeHandle TypeOf<T>()
Returns
| Type | Description |
|---|---|
| RuntimeTypeHandle | The runtime handle representing type |
Type Parameters
| Name | Description |
|---|---|
| T | The type which runtime handle should be obtained. |