Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Rotate array data question

Rotate array data question

Scheduled Pinned Locked Moved C#
questiondata-structures
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joshua Lunsford
    wrote on last edited by
    #1

    if i have a array string[] myArray = {"Wes","Josh","Dave"}; and i want to rotate the order ever so often programmically what is the best way to do that? The program will know when it wants dave to be first but then wes needs to be second and so forth.

    N N 2 Replies Last reply
    0
    • J Joshua Lunsford

      if i have a array string[] myArray = {"Wes","Josh","Dave"}; and i want to rotate the order ever so often programmically what is the best way to do that? The program will know when it wants dave to be first but then wes needs to be second and so forth.

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Then retreive the values using the index in the order you would like


      only two letters away from being an asset

      1 Reply Last reply
      0
      • J Joshua Lunsford

        if i have a array string[] myArray = {"Wes","Josh","Dave"}; and i want to rotate the order ever so often programmically what is the best way to do that? The program will know when it wants dave to be first but then wes needs to be second and so forth.

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        Hello

        string[] MyArray = {"Wes","Josh","Dave"};

        private void Rearrange(byte OldIndex, byte NewIndex)
        {
        string Temp = MyArray[OldIndex];
        MyArray[OldIndex] = MyArray[NewIndex];
        MyArray[NewIndex] = Temp;
        }

        Regards:rose:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups