如何在函数中检查对象是否属于某种类型。这是我的代码:
Public Function IsSerializedObjectAValidObjectType(Of ObjectType)(FileName As String) As Boolean
Dim ObjectToCheck As New Object
ObjectToCheck = OpenObjectFromFile(FileName)
Return ObjectToCheck.GetType Is ObjectType
End Function
以下代码从文件中获取对象。
ObjectToCheck = OpenObjectFromFile(FileName)