I have an array of drive letters and I need to append a colon to each letter and then pass the array to another function. Can I do this or do I need to create a new array? Or maybe not an array at all but some kind of List instead?
string source = "C|D|E";
string[] sourcearray = source.Split('|');
foreach (string driveletter in sourcearray)
{
//need to append ":" to each drive letter
}
EDIT: There are times when the source array could end in a pipe:
string source = "C|D|E|";
When that happens the last element in the array will be a colon if I use a common for loop, and I can’t have this. How best to handle this? When this happens the final array needs to look like:
C: D: E:
Thanks.
Strings are immutable, so you can’t change the string instance but you must change the array slots with new strings: