473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

split and converting

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,
Aug 25 '08 #1
3 1682
CSharper wrote:
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
Aug 25 '08 #2
Alun Harford wrote:
CSharper wrote:
>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));
Hmm... that's not very clear. Or right.

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

Alun Harford
Aug 25 '08 #3
Excellent, thanks.
On Aug 25, 1:25*pm, Alun Harford <devn...@alunharford.co.ukwrote:
Alun Harford wrote:
CSharper wrote:
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));

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

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

Alun Harford
Aug 25 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
9
by: Will McGugan | last post by:
Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. ...
14
by: Richard | last post by:
I have a large list of two element tuples. I want two separate lists: One list with the first element of every tuple, and the second list with the second element of every tuple. Each tuple...
6
by: Prit | last post by:
Hi everyone I guess this should be a simple question for the gurus I have a Data in a column which is to be places in 2 columns instead of one. How do i go about doing it in MS SQL server? Could...
1
by: pemigh | last post by:
I have a report with pages breaking in the middle of text box controls. And it's not just on a line-by-line basis, but sometimes (in a situation that I can no longer recreate) just the bottom...
5
by: MDB | last post by:
Hello all, I have having problems figuring out how to split on a string rather than a char. Any help would be appreciated. Here is what I am trying to do. string...
2
by: Willempie | last post by:
We are converting our asp app to dotNet. Our app is divide into multiple applications (each their own com+ dlls and asp pages). So, in dotNet we ave different assemblies for the busines,data access...
4
by: Ori :) | last post by:
Hi guys I have a 50 charecters long string and I need to examine every charectar individually, I thought of converting the string into and Char array of 50 and then go over the array, how can I...
3
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I have the following code. bit it gives me error that The best overload method for string.Split(params char) has some invalid arguments. I am using stringbuilder which doesn't have split method so...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.