split and converting

C

CSharper

I have a string which is seprated by . and I want to split it and
convert it in a single line of code (using lambda may be), is it
possible? I have already verified all the characters in the string is
integer or .
For example the input string could be something like 1.2.3 and I want
the integer array to have 1, 2, 3 as three individual elements.
Thanks,
 
A

Alun Harford

CSharper said:
I have a string which is seprated by . and I want to split it and
convert it in a single line of code (using lambda may be), is it
possible? I have already verified all the characters in the string is
integer or .
For example the input string could be something like 1.2.3 and I want
the integer array to have 1, 2, 3 as three individual elements.
Thanks,

string.Split('.').Select(s=>int.Parse(s));

Alun Harford
 
A

Alun Harford

Alun said:
string.Split('.').Select(s=>int.Parse(s));

Hmm... that's not very clear. Or right.

inputString.Split('.').Select(s=>int.Parse(s)).ToArray();

Alun Harford
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top