Is there some equivalent to the StringBuilder.Insert method for use with byte arrays? I was going to try and use a MemoryStream but an error was thrown telling me that the MemoryStream object is “not expandable”. I need to place bytes within specific spots of another (already existing byte array).
Here is the same idea using StringBuilder.
String firstString = "FirstData";
String someString = "string Data";
int Index = 0;
StringBuilder sb = new StringBuilder(firstString);
for(int i = 0; i < someString.Length; i++)
{
sb.Insert(index, someString[i]);
index += 2;
}
Thank you for any help,
Evan
Use a List; which will allow you to insert as needed. If you have an existing array you can call
ToList().Then to go back to an array simply call
ToArray().