Remove element from array - CSharp System

CSharp examples for System:Array Slice

Description

Remove element from array

Demo Code


using System.Linq;
using System;// w ww .j av  a  2 s  .  c o  m
using System.Collections.Generic;
using System.Collections;
using UnityEngine;

public class Main{
        public static void Remove<T>(this T[] self, T toRemove)
            where T : class
        {
            if (self == null)
            {
                return;
            }

            for (int i = 0; i < self.Length; i++)
            {
                if (self[i] == toRemove)
                {
                    self[i] = null;
                }
            }
        }
}

Related Tutorials