Type.IsAssignableTo(Type) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether the current type can be assigned to a variable of the specified targetType
.
public:
bool IsAssignableTo(Type ^ targetType);
public bool IsAssignableTo (Type? targetType);
member this.IsAssignableTo : Type -> bool
Public Function IsAssignableTo (targetType As Type) As Boolean
Parameters
- targetType
- Type
The type to compare with the current type.
Returns
true
if any of the following conditions is true:
The current instance and
targetType
represent the same type.The current type is derived either directly or indirectly from
targetType
. The current type is derived directly fromtargetType
if it inherits fromtargetType
; the current type is derived indirectly fromtargetType
if it inherits from a succession of one or more classes that inherit fromtargetType
.targetType
is an interface that the current type implements.The current type is a generic type parameter, and
targetType
represents one of the constraints of the current type.The current type represents a value type, and
targetType
representsNullable<c>
(Nullable(Of c)
in Visual Basic).
false
if none of these conditions are true, or if targetType
is null
.
Applies to
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk