# NotBe

`ShouldNotBe` is the inverse of `ShouldBe`.

## Objects

`ShouldNotBe` works on all types and compares using `.Equals`.

```cs
var theSimpsonsCat = new Cat { Name = "Santas little helper" };
theSimpsonsCat.Name.ShouldNotBe("Santas little helper");
```

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

**Exception**

```
theSimpsonsCat.Name
    should not be
"Santas little helper"
    but was
```

## Numeric

`ShouldNotBe` also allows you to compare numeric values, regardless of their value type.

### Integer

```cs
const int one = 1;
one.ShouldNotBe(1);
```

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

**Exception**

```
one
    should not be
1
    but was
```

### Long

```cs
const long aLong = 1L;
aLong.ShouldNotBe(1);
```

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

**Exception**

```
aLong
    should not be
1L
    but was
```

## DateTime(Offset)

`ShouldNotBe` DateTime overloads are similar to the numeric overloads and also support tolerances.

```cs
var date = new DateTime(2000, 6, 1);
date.ShouldNotBe(new(2000, 6, 1, 1, 0, 1), TimeSpan.FromHours(1.5));
```

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

**Exception**

```
date
    should not be within
01:30:00
    of
2000-06-01T01:00:01.0000000
    but was
2000-06-01T00:00:00.0000000
```

## TimeSpan

`TimeSpan` also has tolerance overloads

```cs
var timeSpan = TimeSpan.FromHours(1);
timeSpan.ShouldNotBe(timeSpan.Add(TimeSpan.FromHours(1.1d)), TimeSpan.FromHours(1.5d));
```

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

**Exception**

```
timeSpan
    should not be within
01:30:00
    of
02:06:00
    but was
01:00:00
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shouldly.org/documentation/equality/notbe.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
