c# how to add byte to byte array

前端 未结 6 616
梦毁少年i
梦毁少年i 2020-12-08 15:30

How to add a byte to the beginning of an existing byte array? My goal is to make array what\'s 3 bytes long to 4 bytes. So that\'s why I need to add 00 padding in the beginn

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 16:10

    To prevent recopy the array every time which isn't efficient

    What about using Stack

    csharp> var i = new Stack();
    csharp> i.Push(1);
    csharp> i.Push(2); 
    csharp> i.Push(3); 
    csharp> i; { 3, 2, 1 }
    
    csharp> foreach(var x in i) {
      >       Console.WriteLine(x);
      >     }
    

    3 2 1

提交回复
热议问题