> > I am trying to split an Array into another array. Each value in the
> > array has tab delimited strings.
[quoted text clipped - 22 lines]
>
> Jon
> Its one long string.
> There are \r\n's at the end of rows and and \t's at the end of
> datapoints
> I want each row to be an Array by itself.
Do you particularly need the container to be an array? Are you happy
with a list instead?
Something like:
List<string[]> output = new List<string[]>();
foreach (string line in originalText.Split(new string[]{"\r\n"},
StringSplitOptions.None))
{
output.Add(line.Split('\t'));
}
Alternatively, if you're using C# 3 and .NET 3.5, and don't mind an
IEnumerable<string[]>:
var output = originalText.Split(new[]{"\r\n"}, StringSplitOptions.None)
.Select(line => line.Split('\t'));
(Call ToList if you'd rather get a list out.)

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
AMP - 11 Mar 2008 19:33 GMT
> > Its one long string.
> > There are \r\n's at the end of rows and and \t's at the end of
[quoted text clipped - 25 lines]
> Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk
Jon,
I am using your first suggestion,and it works. I need to do more
analysing of the numbers so this is best.
BUT, I am getting 19 elements for the Sub array and there are only 18
datapoints. There is an extra empty string element at the end of each.
Why? and can I get rid of it without for/eaching every Array?
Thanks
Mike
Jon Skeet [C# MVP] - 11 Mar 2008 19:49 GMT
<snip>
> I am using your first suggestion,and it works. I need to do more
> analysing of the numbers so this is best.
> BUT, I am getting 19 elements for the Sub array and there are only 18
> datapoints. There is an extra empty string element at the end of each.
> Why? and can I get rid of it without for/eaching every Array?
The easiest thing would be to use StringSplitOptions.RemoveEmptyEntries
:)

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk