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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -