Checks whether a value can be an instance of type when, for example,
value is passed to a method with type parameter type.
KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.0.0
public static bool CanAcceptValue(
this Type type,
Public Shared Function CanAcceptValue (
type As Type,
value As Object
) As Boolean
static bool CanAcceptValue(
static member CanAcceptValue :
type : Type *
value : Object -> bool
- type Type
- The type to check.
- value Object
- The value, whose compatibility with the type is checked.
can be an instance of type
.In Visual Basic and C#, you can call this method as an instance method on any object of type Type
. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic)
or Extension Methods (C# Programming Guide)
type can be a NullableT type.
If type is passed by reference, then the element type is checked.
If either type or value is enum, then its underlying type is also accepted because both can be unboxed from an Object without casting errors.