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. merging byt[] in c#

merging byt[] in c#

Scheduled Pinned Locked Moved C#
csharp
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.
  • G Offline
    G Offline
    GauravKP
    wrote on last edited by
    #1

    Hello..... I want to merge 2 or more byte[] in to a single byte[],plz suggest a C# code for this . Thanx.

    C D 2 Replies Last reply
    0
    • G GauravKP

      Hello..... I want to merge 2 or more byte[] in to a single byte[],plz suggest a C# code for this . Thanx.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Create a new array of the right size and copy the two arrays into place.

      Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

      1 Reply Last reply
      0
      • G GauravKP

        Hello..... I want to merge 2 or more byte[] in to a single byte[],plz suggest a C# code for this . Thanx.

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        Array.Copy is what you need - something like

        byte[] a = new byte[] { 0, 1, 2, 3 };
        byte[] b = new byte[] { 4, 5, 6, 7 };
        byte[] c = new byte[a.Length + b.Length];
        Array.Copy(a, c, a.Length);
        Array.Copy(b, 0, c, a.Length, b.Length);
        foreach (byte item in c)
        {
        Console.WriteLine(item);
        }

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
        Why are you using VB6? Do you hate yourself? (Christian Graus)

        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