0

Please help how do I convert int to string. For example

int num = 9;
Console.WriteLine(num.ToString("X"));

Will display

9

Expected Output:

9 = nine

Sinatr
  • 20,892
  • 15
  • 90
  • 319

1 Answers1

0

So you want to write "nine" not "9"?

In the former case you'll have to use a selection statement, preferably switch/case.

eg

int num = 9
string stringNum;
switch (num)
{
    case 9:
        stringNum = "nine";
        break;
}

In the latter case, you can just print the integer.

Console.WriteLine(num);
Jonah Mann
  • 23
  • 5
  • 1
    *Latter* is what OP already doing. Can you demonstrate `switch/case` example in you answer? Otherwise it's too short for an answer (basically a suggesting comment without *real* solution). – Sinatr Jul 03 '15 at 11:06
  • I added switch example code. – Jonah Mann Jul 03 '15 at 11:12