How to take user input, convert it integer, and print it on screen?

How can I take user input from keyboard, convert it into integer, and print it on the screen using Unity C#.

void Update()
{
foreach (char c in Input.inputString)
{
Debug.Log((int)c);
}
}

Input.inputString returns a string of the pressed keys. A string is just a…string of characters. You can iterate a string with a foreach loop so that you get each char separately:

string str = "Cat";
foreach(char c in str){ Debug.Log(c); }

prints

 C 
 a  
 t

Based on the ASCII table, a char has a given integer value, Unity actually uses Unicode which extends the ASCII table with local characters (letters specific to a language like ç or å or else).

Casting the char to integer automatically returns the ASCII/Unicode value. You can then check whether a letter or number was pressed:

 if((int) c >= 48 && (int)c <= 57){ // Number }
 else if((int) c >= 65 && (int)c <= 90){ // Letter }
 else { // Something else }

Since it is Unicode the letter part will only returns letter from the English alphabet so if you go for Chinese or Indian, you would have to set the value accordingly based on that huge table.