Prepending a string to a string[]

  • Thread starter Thread starter David P. Donahue
  • Start date Start date
D

David P. Donahue

There must be something I'm missing, but is there an easy way to add a
given string as the first element in a string[] after the string[] is
created (from, say, a Directory.GetFiles function call)?


Regards,
David P. Donahue
(e-mail address removed)
 
David P. Donahue said:
There must be something I'm missing, but is there an easy way to add a
given string as the first element in a string[] after the string[] is
created (from, say, a Directory.GetFiles function call)?

No. Arrays are fixed size. You need to create a new array with the
bigger size, put the string into the first element, then copy the array
into the rest.
 
Back
Top