Extension methods for Type.
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
See Also: Inherited members from object.
⊟ Public Methods
staticIsAssignableTo (this Type, Type) : bool Determines whether an instance of self can be stored in a reference of a type type. staticIsNullable (this Type) : bool Gets a value indicating whether the type is a nullable type.
⊟ IsAssignableTo Method
Determines whether an instance of self can be stored in a reference of a type type.
⊟ See Also
⊟ Parameters
⊟ Returns
true if an instance of type self can be stored into a reference of type type; otherwise, false.⊟ Exceptions
Type Reason ArgumentNullException self is null. ⊟ Remarks
This is equivalent to type.IsAssignableFrom(self).
C# Example // Can string be implicitly converted to object? Yes. Assert.IsTrue (typeof(string).IsAssignableTo (typeof (object))); // Can object be implicitly converted to string? No. Assert.IsFalse (typeof(object).IsAssignableTo (typeof (string)));⊟ Requirements
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
⊟ IsNullable Method
Gets a value indicating whether the type is a nullable type.
⊟ Parameters
- self
- A Type containing the type to check.
⊟ Returns
true if self is a Nullable<T> type; otherwise, false.⊟ Exceptions
Type Reason ArgumentNullException self is null. ⊟ Remarks
self is considered to a nullable type if:
- self is not typeof(Nullable<>).
- self.GetGenericTypeDefinition() is typeof(Nullable<>).
C# Example Assert.IsTrue (typeof (int?).IsNullable ()); Assert.IsFalse (typeof (int).IsNullable ()); Assert.IsFalse (typeof (string).IsNullable ()); Assert.IsFalse (typeof (Nullable<>).IsNullable ());⊟ Requirements
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0