Show / Hide Table of Contents

Class Intrinsics

Represents highly optimized runtime intrinsic methods.

Inheritance
Object
Intrinsics
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public static class Intrinsics : object

Methods

| Improve this Doc View Source

Bitcast<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.

| Improve this Doc View Source

DefaultOf<T>()

Returns default value of the given type.

Declaration
public static T DefaultOf<T>()
Returns
Type Description
T

The default value of type T.

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.

| Improve this Doc View Source

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 flag are also set in value; otherwise, false.

Type Parameters
Name Description
T
| Improve this Doc View Source

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
| Improve this Doc View Source

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 T is nullable type; otherwise, false.

Type Parameters
Name Description
T

The type to check.

Remarks

This method always returns true for all reference types and . On mainstream implementations of .NET CLR, this method is replaced by constant value by JIT compiler with zero runtime overhead.

| Improve this Doc View Source

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 T.

Type Parameters
Name Description
T

The type which runtime handle should be obtained.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX