- Home /
Converting strings to numbers
I'm making a little text parser in Unity, but I have come to needing to conver a string, containing only numbers, directly into integers, I know that I can do this with a little bit of length code that goes character by character comparing each character to another and returning an integer, but i'm wondering if there is a faster way I can accomplish the task of turning the string "932" into the integer 932.
Answer by aldonaletto · Jul 31, 2013 at 02:45 AM
Use parseInt:
var n: int = parseInt(someString);
There's also parseFloat for float values.
Thank you! Also, I asked another seperate question for searching a text document for a string, is there a parse function for that?
You could use .Net/$$anonymous$$ono functions like Contains or IndexOf - I've answered your other question too.