none
Move array position by one?

    Question

  • Does a function already exist in .NET or Linq that will move a the value of each array position up by one and drop the value that doesn't fit. For example.

    arr[] {"A", "B", "C"}

    then adding X to position 0 moving all up one to look like

    arr[]{"X", "A", "B"}

    I'm not looking for code, just a simple yes and the name of the function or a no. 

    Thank you kindly!

    Wednesday, September 28, 2016 4:23 PM

Answers

  • I'm afraid, out of the box the Array class hasn't got such a function.

    But by using the methods Enqueue() and Dequeue() of the Queue class you can achieve something very similar to that. A Queue is described as a circular array where objects  are inserted at one end and removed from the other.

    wizend

    • Marked as answer by Jmair Wednesday, September 28, 2016 6:27 PM
    Wednesday, September 28, 2016 6:24 PM