KGy SOFT

TypeExtensionsCanAcceptValue Method

KGy SOFT Core Libraries Help
Checks whether a value can be an instance of type when, for example, value is passed to a method with type parameter type.

Namespace:  KGySoft.CoreLibraries
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.4.0
Syntax

public static bool CanAcceptValue(
	this Type type,
	Object value
)

Parameters

type
Type: SystemType
The type to check.
value
Type: SystemObject
The value, whose compatibility with the type is checked.

Return Value

Type: Boolean
 if value can be an instance of type; otherwise, .

Usage Note

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).
Exceptions

ExceptionCondition
ArgumentNullExceptiontype is .
Remarks

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.

See Also

Reference