c# - Insert string value to object array -
i have below array of type object
object[] myarray = new object[] { "1", "success"};
i want insert string value @ first position in myarray there method result should below:
i want array below
object[] myarray = new object[] { "logfile","1", "success"};
if need stick array:
myarray = new object[]{"logfile"}.concat(myarray).toarray();
the classic, non-linq (and efficient) way use array.copy
:
var newarray = new object[myarray.length + 1]; newarray[0] = "logfile"; array.copy(myarray, 0, newarray, 1, myarray.length); // myarray = newarray;
Comments
Post a Comment