> For the complete documentation index, see [llms.txt](https://docs.shouldly.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shouldly.org/documentation/equality/oftype.md).

# OfType

`ShouldBeOfType` is the inverse of `ShouldNotBeOfType`.

## ShouldBeOfType

```cs
var theSimpsonsDog = new Cat { Name = "Santas little helper" };
theSimpsonsDog.ShouldBeOfType<Dog>();
```

[snippet source](https://github.com/shouldly/shouldly/blob/master/src/DocumentationExamples/CodeExamples/ShouldBeOfTypeExamples.ShouldBeOfType.codeSample.approved.cs#L1-L2) | [anchor](#snippet-ShouldBeOfTypeExamples.ShouldBeOfType.codeSample.approved.cs)

**Exception**

```
theSimpsonsDog
    should be of type
Simpsons.Dog
    but was
Simpsons.Cat
```

## ShouldNotBeOfType

```cs
var theSimpsonsDog = new Cat { Name = "Santas little helper" };
theSimpsonsDog.ShouldNotBeOfType<Cat>();
```

[snippet source](https://github.com/shouldly/shouldly/blob/master/src/DocumentationExamples/CodeExamples/ShouldBeOfTypeExamples.ShouldNotBeOfType.codeSample.approved.cs#L1-L2) | [anchor](#snippet-ShouldBeOfTypeExamples.ShouldNotBeOfType.codeSample.approved.cs)

**Exception**

```
theSimpsonsDog
    should not be of type
Simpsons.Cat
    but was
Santas little helper
```
