Friday, April 28, 2006

Copying one string array to another  [Digg.com This!]

Say you have an array origArray declared as:

string[] origArray;

that contains a number of string items created, for example, like this:

origArray = csvLine.Split(',');

I wanted to copy those strings into a new array dependent on some criteria. This can be achieved as so:

// Create new empty array
string[] outArray = new string[origArray.Length];

for (int i = 0; i <>
{
outArray[i] = (string)tagArray[i].Clone();
}

(I'm missing my criteria, but I have an if statement before I do the clone and do something else otherwise.)

0 Comments:

Post a Comment

<< Home