Create a new array by removing given amount of element on the right. - CSharp System

CSharp examples for System:Array Create

Description

Create a new array by removing given amount of element on the right.

Demo Code

// Permission is hereby granted, free of charge, to any person obtaining a copy
using System;/*from w ww  .ja  va 2s . c om*/

public class Main{
        /// <summary>
      ///   Create a new array by removing given amount of element on the right.
      /// </summary>
      public static T[] TrimRight<T> (T[] array, int amount)
      {
         T[] result = new T[array.Length - amount];
         Array.Copy (array, 0, result, 0, result.Length);
         return result;
      }
}

Related Tutorials