RSS

How to remove an item from an array using C# ?

15 Sep

618326165_90a2527003

private static void RemoveArrayItem<T>(ref T[] inArray, int inIndex)
{
  T[] newArray = new T[inArray.Length - 1];
    for (int i = 0, j = 0; i < newArray.Length; i++, j++)
    {
        if (i == inIndex)
        {
            j++;
        }
        newArray[i] = inArray[j];
    }
    inArray = newArray;
}
 
Leave a comment

Posted by on September 15, 2012 in Visual C# . NET

 

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: