共用方式為


Assert.IsInstanceOfType 方法 (Object, Type)

確認指定的物件是指定之型別的執行個體。 如果此型別不在物件的繼承階層架構內,判斷提示就會失敗。

命名空間:  Microsoft.VisualStudio.TestTools.UnitTesting
組件:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

語法

'宣告
Public Shared Sub IsInstanceOfType ( _
    value As Object, _
    expectedType As Type _
)
public static void IsInstanceOfType(
    Object value,
    Type expectedType
)
public:
static void IsInstanceOfType(
    Object^ value, 
    Type^ expectedType
)
static member IsInstanceOfType : 
        value:Object * 
        expectedType:Type -> unit
public static function IsInstanceOfType(
    value : Object, 
    expectedType : Type
)

參數

  • value
    類型:Object

    要驗證的物件屬於 expectedType。

  • expectedType
    類型:Type

    必須要位於 value 之繼承階層架構中的型別。

例外狀況

例外狀況 條件
AssertFailedException

value 為 nullnull 參考 (即 Visual Basic 中的 Nothing) 或 expectedType 不在 value 的繼承階層架構內。

.NET Framework 安全性

請參閱

參考

Assert 類別

IsInstanceOfType 多載

Microsoft.VisualStudio.TestTools.UnitTesting 命名空間

其他資源

使用 Assert 類別