How do you get a certain part of an objects name?

I have an 8x8 grid of cubes and they’re named Cube (1), Cube (2), Cube (3)… Cube (64). I have a ray and I need to check the part that’s inside the parenthesis of the cube they clicked. In other words, if they clicked Cube (24), it’ll spit out 24.

if (Input.GetMouseButtonUp(0))
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            int id = 0;
            if (Physics.Raycast(ray, out hit, 100))
                //set id to the number in the parenthesis of the cube I clicked

id = System.Convert.ToInt32 ( (new string {“(”, “)”}, System.StringSplitOptions.RemoveEmptyEntries)[1]);
This should do it (you can remove ‘System’ if you are importing it, which is the default in C#). You may have to split it into a different variable, i.e.

string[] s = (new string[] {"(", ")"}, System.StringSplitOptions.RemoveEmptyEntries);
id = System.Convert.ToInt32 (s[1]);