---
tags:
    - "Dice"
    - "Range"
    - "Whole"
    - "Int"
    - "Roll"
---

# Random Integer

[Random](index.md) / **Random Integer**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns a random whole number between two values, both included

## Parameters

| Name | Description |
| :--- | :---------- |
| Min | The lowest value that can be returned |
| Max | The highest value that can be returned |

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;
using Random = UnityEngine.Random;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Random Integer")]
    [Category("Random/Integer")]

    [Description("Returns a random whole number between two values, both included")]
    [Image(typeof(IconDice), ColorTheme.Type.Yellow, typeof(BadgeZ))]

    [Parameter("Min", "The lowest value that can be returned")]
    [Parameter("Max", "The highest value that can be returned")]

    [Keywords("Dice", "Range", "Whole", "Int", "Roll")]

    [Serializable]
    public class TypeNumberRandomInteger : TypeNumber
    {
        [SerializeField] private GetInteger m_Min = new GetInteger(0);
        [SerializeField] private GetInteger m_Max = new GetInteger(10);

        public override double Get(Args args)
        {
            int min = this.m_Min.GetInt(args);
            int max = this.m_Max.GetInt(args);

            return min <= max
                ? Random.Range(min, max + 1)
                : Random.Range(max, min + 1);
        }

        public override string ToString()
        {
            return $"Random Integer({this.m_Min}, {this.m_Max})";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnUpdate;
    }
}

```

