String split and index [0]

G

Guest

Hi,

I need to split a string and then take the 0th element of the resultant
array. what could be a good shortcut? like 1 statement instead of 3,4

Thnx
 
K

Karl Seguin [MVP]

I'd say:
input.Split(' ')[0];

but why not create a a function?
string s = GetFirstIndexFromSplit(input, ' ');

it's easier to test and maintain...

karl
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top