String split and index [0]

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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

Back
Top