Fill an array - CSharp System

CSharp examples for System:Array Element

Description

Fill an array

Demo Code


using System.Collections;
using UnityEngine;

public class Main{
    public static void Fill<T>(this T[,] originalArray, T with) {
         for(int i = 0; i < originalArray.GetLength(0); i++){
            for (int j = 0; j < originalArray.GetLength(1); j++)
            {/*from  w  w w.  java 2 s  . c o  m*/
               originalArray[i, j] = with;   
            }
         }
      }
    public static void Fill<T>(this T[] originalArray, T with) {
         for(int i = 0; i < originalArray.Length; i++){
            originalArray[i] = with;
         }
      }
}

Related Tutorials