- Home /
using char to extract integer numbers from a list - [UnityScript]
I basically have an XML Parser I bought from the Asset store. It stores the values it grabs from the XML file as char ( I think ).
Somebody on the forum helped me in my post regarding XML and reading the values but I have tried to use char to convert these values to integers. The numbers stored in the list consist of numbers only.
The person used charAt to convert them but I haven't found an equivalent for UNITYSCRIPT.
So basically if I had a list full of numbers as char how would I then convert them to integers?
Thanks!
Answer by robertbu · Aug 06, 2013 at 03:54 PM
Here are a couple of methods depending on whether you want to treat the character as a 'byte' with or if you are you looking for the a string convert (i.e. '2' would equal 2).
var arch : char[] = ["0"[0], "1"[0], "2"[0], "3"[0]];
function Start () {
var i : int = System.Convert.ToInt32(arch[2]);
Debug.Log("i: " + i);
var j : int = char.GetNumericValue(arch[2]);
Debug.Log("j: " + j);
}
Your answer
Follow this Question
Related Questions
Convert a char to int / float 2 Answers
A node in a childnode? 1 Answer
convert GUI.tooltip to int 1 Answer
How do you find an Index of an Arrayed/Listed Object? 2 Answers
Is there a way to remove array entries in the editor? 4 Answers