String split and index [0]

Discussion in 'ASP .Net' started by =?Utf-8?B?ZG90bmV0dGVzdGVy?=, May 3, 2006.

  1. 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
    =?Utf-8?B?ZG90bmV0dGVzdGVy?=, May 3, 2006
    #1
    1. Advertising

  2. 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
    --
    http://www.openmymind.net/
    http://www.fuelindustries.com/


    "dotnettester" <> wrote in message
    news:...
    > 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
    >
    Karl Seguin [MVP], May 3, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    457
  2. Carlos Ribeiro
    Replies:
    11
    Views:
    689
    Alex Martelli
    Sep 17, 2004
  3. Sam Kong
    Replies:
    5
    Views:
    231
    Rick DeNatale
    Aug 12, 2006
  4. Stanley Xu
    Replies:
    2
    Views:
    595
    Stanley Xu
    Mar 23, 2011
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    271
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page