Skip to content

TypeExtensions

Namespace: SideXP.Core

public static class TypeExtensions

Extension functions for Type instances.

Methods

Inherits(Type, Type)

public static bool Inherits(Type type, Type parent)

Checks if a given type inherits from a given parent type. Note that if the given type is the same as the expected parent type, this function will return false, as it's not true that the given type inherits from itself.

Parameters

  • type: The type to check.
  • parent: The expected parent type.

Returns

Returns true if the given type inherits from the parent type.

Inherits<TParent>(Type)

public static bool Inherits<TParent>(Type type)

Checks if a given type inherits from a given parent type. Note that if the given type is the same as the expected parent type, this function will return false, as it's not true that the given type inherits from itself.

Type parameters

  • TParent

Returns

Returns true if the given type inherits from the parent type.

Is(Type, Type)

public static bool Is(Type type, Type parent)

Checks if a given type is or inherits from a given parent type.

Parameters

  • type: The type to check.
  • parent: The expected parent type.

Returns

Returns true if the given type is or inherits from the parent type.

Is<TParent>(Type)

public static bool Is<TParent>(Type type)

Checks if a given type is or inherits from a given parent type.

Type parameters

  • TParent

Parameters

  • type: The type to check.

Returns

Returns true if the given type is or inherits from the parent type.