have i got the idea of tryparse wrong, i am trying to convert an int to string then back to int but it only returns 0, anyone got any idea how this works, i need the converted int to match the original int after conversion
code below thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class INTTOHEXCHECK2 : MonoBehaviour {
public int Score;
private int myNewInt;
// Use this for initialization
void Start () {
string myHex = Score.ToString("X");
int.TryParse(myHex, out myNewInt); // ONLY RESULTS CONVERTING TO 0
Debug.Log("Score "+ Score + " HEX "+ myHex + " BACKTOINT "+ myNewInt);
}
}
you are converting to hexadecimal, it might contain letters. (then int parse fails).
try printing out the “myHex” to check,
also int.TryParse() returns true or false, can check that too.
or look for code to convert hex value into integer.