Is it possible to do something like
byte[] byteArray = new byte[100]
byteArray = {0x00, 0x01, 0x02, 0x03, ... , 0x10}
and then set the rest of the variables later?
I would rather avoid using:
byteArray[0] = 0x00;
byteArray[1] = 0x01;
and so on
Sorry, I should have made it more clear that I want to set maybe half the values at once, then fill the rest in later. I’ll go with a list
If you mean can you create an array of 100 items and set 5 of them in-line, something like:
Then no, you’ll get a compiler error:
However, you can do in-line initialization of all items:
Or more tersely (the compiler can infer this as an
int[]):A half-way house is to instead use a list, which can grow in size later:
Then you can change this to an array as needed:
There are loads of alternatives, but without knowing much about where these values are coming from, I’m hesitant to keep listing them.