# IsNotNull

> Assert that the value is not null.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Assertions](/engine/6000.0/script-reference/unityengine/assertions.md)
* **Assembly:** UnityEngine.CoreModule

## IsNotNull\<T>(T)

Assert that the value is not null.

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void IsNotNull<T>(T value) where T : class
```

### Parameters

**** (T): The Object or type being checked for.

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;

public class AssertionExampleClass : MonoBehaviour
{
    MyClass myClassReference;

    void Update()
    {
        // Make sure the myClassReference reference is set
        Assert.IsNotNull(myClassReference);
    }
}

public class MyClass {}
```

## IsNotNull\<T>(T, string)

Assert that the value is not null.

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void IsNotNull<T>(T value, string message) where T : class
```

### Parameters

**** (T): The Object or type being checked for.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The string used to describe the [Assert](/engine/6000.0/script-reference/unityengine/assertions/assert.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;

public class AssertionExampleClass : MonoBehaviour
{
    MyClass myClassReference;

    void Update()
    {
        // Make sure the myClassReference reference is set
        Assert.IsNotNull(myClassReference);
    }
}

public class MyClass {}
```

## IsNotNull(Object, string)

Assert that the value is not null.

```csharp
[Conditional("UNITY_ASSERTIONS")]
public static void IsNotNull(Object value, string message)
```

### Parameters

**** (\[Object]\(/engine/6000.0/script-reference/unityengine/object)): The Object or type being checked for.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The string used to describe the [Assert](/engine/6000.0/script-reference/unityengine/assertions/assert.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Assertions;

public class AssertionExampleClass : MonoBehaviour
{
    MyClass myClassReference;

    void Update()
    {
        // Make sure the myClassReference reference is set
        Assert.IsNotNull(myClassReference);
    }
}

public class MyClass {}
```
