How to make array to non-same random value?

using UnityEngine;
using System.Collections;

public class Apple : MonoBehaviour {

public int[] a; 	

void Start () {

	a = new int[4];

	Shuffle ();


public void Shuffle(){

	for (int i = 0; i < a.Length; i++) {
			a  *= Random.Range (0, 20);*

_ Debug.Log (a );_
* }*
* }*
Result > 0,9,18,9 …
‘9’ is Same. i dont want that value.
How to make array to non-same random value?

You can check if the number that you generated is already in the array by using the IndexOf(int) method.

for (int i = 0; i < a.Length; i++) {
     int random = Random.Range(0,20);
     while(a.IndexOf(random)> -1)
          random = Random.Range(0,20);//This will keep on generating a number until there is no repeat
     a  *= random;*

Debug.Log (a );

Now be weary that if the array is longer, the values from 0-20 may be all taken up so the while loop will keep running forever because there is no way for it to make a number that isn’t already in the array. Hope this helps!

Generate a list of integers between your desired min and max values.

Extract the amount of elements you need, updating the list.

Back-of-envelope suggestion:

List<int> ints = new List<int>();
List<int> values = new List<int>();
int min = 0;
int max = 20;
int needed = 5;

for (int i = min; i <= max; ++i) {

for (int i = 0; i < needed; ++i) {
  int index = Random.Range(0, ints.Count);

Note that this solution does no bounds checking, and will throw an exception when you request more values than exist between max and min.