c# - Is there any option to make get encoding return the required number of bytes matching the target byte array -


I have a byte array defined as

  byte [] goal has gone;   

Now when I call

  target = encoding.Ascii.GetBytes (input);   

Returned bytes are only 3. But I need a 4-byte array. Is there any way to back 3 bites padded with 0 bytes so that I get a byte array of length 4

The simple way to copy the temporary byte array is:

  byte [] target = new byte [4]; Byte [] bytes = encoding ASCII.GetBytes ("abc"); Array.Copy (Byte, 0, Goal, 1, Bytes Lang.);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -