# NullOrEmpty-Checks

{% hint style="info" %}
Included since 📦**v1.1.0**
{% endhint %}

### **Regular version**

#### **Summary**

The extension methods `IsNullOrEmpty()` and `IsNullOrWhiteSpace()` return a boolean value that indicates whether the value of the string instance is null / empty / only consisting of whitespace characters.

They mirror the behaviour of the string class's pre-existing methods of the same name.

#### **Example**

```csharp
// Suppose we have a string variable.
var myString = "foo";

// This library lets you check whether it is null or empty (or whitespace)
// using an extension method.
myString.IsNullOrEmpty();
myString.IsNullOrWhiteSpace();

// In each case a boolean value is returned indicating the answer
// (here: 'false').
```

#### **Equivalent to**

```csharp
// Conventionally, one would check whether the string is null or empty
// (or whitespace) like this:
string.IsNullOrEmpty(myString);
string.IsNullOrWhiteSpace(myString);
```

### Negated version

#### **Summary**

The extension methods `IsNotNullOrEmpty()` and `IsNotNullOrWhiteSpace()` return a boolean value that indicates whether the value of the string instance is *not* null / empty / only consisting of whitespace characters.

They mirror the behaviour of the string class's pre-existing methods of similar name (but return the negated result).

#### **Example**

```csharp
// Suppose we have a string variable.
var myString = "foo";

// This library lets you check whether it is *not* null or empty
// (or whitespace) using an extension method.
myString.IsNotNullOrEmpty();
myString.IsNotNullOrWhiteSpace();

// In each case a boolean value is returned indicating the answer
// (here: 'true').
```

#### **Equivalent to**

```csharp
// Conventionally, one would check whether the string is not null or empty
// (or whitespace) like this:
!string.IsNullOrEmpty(myString);
!string.IsNullOrWhiteSpace(myString);
```


---

# 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://mx-pl.gitbook.io/extendedtypes-docs/string/nullorempty-checks.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.
