Remove Last from array - CSharp System

CSharp examples for System:Array Slice

Description

Remove Last from array

Demo Code

// Copyright (c) Microsoft. All rights reserved.
using System.Runtime.CompilerServices;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Diagnostics.Contracts;

public class Main{
        public static T[] RemoveLast<T>(this T[] array)
        {/*from ww  w  .  ja  v a  2s  .  co  m*/
            T[] result = new T[array.Length - 1];
            Array.Copy(array, 0, result, 0, result.Length);
            return result;
        }
}

Related Tutorials