String Manipulation (C#)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron

    #1

    String Manipulation (C#)

    I would like to randomly output phone numbers seperated by \ and / from a string.
    s = "\231-3423/\453-1234/\231-3473/\231-3474/"

    //c sharp code
    private string GetPhoneNum()
    {
    s = "\231-3423/\453-1234/\231-3473/\231-3474/"
    //randomly pick a phone num from string.

    n = randomNum;
    return n;//ie. 453-1234
    }

    Thanks
  • Cor

    #2
    Re: String Manipulation (C#)

    Hi Aaron,

    Have a look at the String.Split methode, does it almost automaticly for you
    (You have to delete the first "\" and the last "/" after using it)

    I hope this helps,

    Cor
    [color=blue]
    > I would like to randomly output phone numbers seperated by \ and / from a[/color]
    string.[color=blue]
    > s = "\231-3423/\453-1234/\231-3473/\231-3474/"
    >
    > //c sharp code
    > private string GetPhoneNum()
    > {
    > s = "\231-3423/\453-1234/\231-3473/\231-3474/"
    > //randomly pick a phone num from string.
    >
    > n = randomNum;
    > return n;//ie. 453-1234
    > }
    >[/color]


    Comment

    Working...