Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How can I split and put string numbers into int?

Hello, I have been trying to make a dice bot with the concepts from the tutorial, but a bit more advanced. One of the bonus feature I am trying to add is to let the user type "3d6" for example and the program to take the 3 and the 6 out to be used in the randomizer. I tried a few things but they didn't work. Ty in advance.

Best Answers

    Accepted Answer

    Use strings to make a char arrays and then you can check for each element in the char array

    Like you can loop through all element and check for weather they are numbers if they are add them to a string and at the end convert that string to int.

    For example think that you have a string "2h6fu72"

    So at the end you will have another string which will be "2672" and then convert it in int.

    You can do so many things with this.

    Accepted Answer

    Char a = '4';

    string b = a.ToString();// "4"

    Int c = Convert.ToInt32(b);//4


Sign In or Register to comment.