Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kieron 152 posts 390 karma points
    Oct 08, 2018 @ 12:38
    Kieron
    0

    Get first word of a string

    Hi, if a string comes in as Bob Johnson, how can i print out just Bob?

    Thanks

    Ps, have tried such like:

    hisName.Split(' ').First()
    

    But getting an error; 'System.Array' does not contain a definition for 'First'

  • MatsStam 50 posts 195 karma points
    Oct 08, 2018 @ 12:41
    MatsStam
    100

    Maybe try hisName.Split(' ')[0] instead then? =)

    Or I'm guessing you need to make it a list or some such first :)

  • Kieron 152 posts 390 karma points
    Oct 08, 2018 @ 12:43
    Kieron
    0

    Cheers mate that worked.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies