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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. can't reasign byte[] array :S

can't reasign byte[] array :S

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
2 Posts 2 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.
  • P Offline
    P Offline
    Patricio Tapia
    wrote on last edited by
    #1

    public ArrayList listcht = new ArrayList(); byte[] comparar = new byte[10]; //W3XVisionHack comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x20; comparar[4] = 0x56; comparar[5] = 0x69; comparar[6] = 0x73; comparar[7] = 0x69; comparar[8] = 0x6f; comparar[9] = 0x6e; listcht.Add(comparar); //W3X1vs1Hack comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x31; comparar[4] = 0x76; comparar[5] = 0x73; comparar[6] = 0x31; comparar[7] = 0x48; comparar[8] = 0x61; comparar[9] = 0x63; listcht.Add(comparar); //W3XCustomKick comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x43; comparar[4] = 0x75; comparar[5] = 0x73; comparar[6] = 0x74; comparar[7] = 0x6f; comparar[8] = 0x6d; comparar[9] = 0x4b; listcht.Add(comparar); } The problem here is the comparar[] array byte can't assign the new values why? they maintaine the old values. well, the sort soluction is redeclare the array

    G 1 Reply Last reply
    0
    • P Patricio Tapia

      public ArrayList listcht = new ArrayList(); byte[] comparar = new byte[10]; //W3XVisionHack comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x20; comparar[4] = 0x56; comparar[5] = 0x69; comparar[6] = 0x73; comparar[7] = 0x69; comparar[8] = 0x6f; comparar[9] = 0x6e; listcht.Add(comparar); //W3X1vs1Hack comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x31; comparar[4] = 0x76; comparar[5] = 0x73; comparar[6] = 0x31; comparar[7] = 0x48; comparar[8] = 0x61; comparar[9] = 0x63; listcht.Add(comparar); //W3XCustomKick comparar[0] = 0x57; comparar[1] = 0x33; comparar[2] = 0x58; comparar[3] = 0x43; comparar[4] = 0x75; comparar[5] = 0x73; comparar[6] = 0x74; comparar[7] = 0x6f; comparar[8] = 0x6d; comparar[9] = 0x4b; listcht.Add(comparar); } The problem here is the comparar[] array byte can't assign the new values why? they maintaine the old values. well, the sort soluction is redeclare the array

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      When you add the array to the list, it's not copied. The list is just a list of references, and you add the reference to the array, not a copy of the array. You add the same array three times to the list, so all the items in the list will be the same actual array. When you change the contents of the array, it will change the contents of all items in the list, as they are all the same object.

      --- single minded; short sighted; long gone;

      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