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'

  • Mats Stam 66 posts 236 karma points
    Oct 08, 2018 @ 12:41
    Mats Stam
    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.

Please Sign in or register to post replies

Write your reply to:

Draft