Q:

How to convert Int To String in C# without using library functions?

What is the most effective code to convert int to string without using a native convert function. 
 public static void Main(string[] args)
    {
        string y = Convert(990);
        Console.WriteLine(y);
        Console.ReadLine(); 
    }

    public static string Convert(int x)
    {

         char[] Str = new char[20];
         int i = 0;
         while (x != 0)
         {
             Str[i++] = x % 10 + '0';
             x = x / 10;
         }

         return Str.ToString();// How do I handle this without the native function?
    }

The above doesnt seem to work. Please advise. 

A:

Here's a solution without a String constructor or a .ToString() call.  This one handles negative numbers.
It's a bit too 'clever' for my taste, but it's an academic exercise anyway...
void Main()
{
    Console.WriteLine(Convert(-5432));
}

String Convert(int i)
{
    return String.Join("",Digits(i).Reverse());
}

IEnumerable<char> Digits(int i)
{
    bool neg = false;
    if(i==0) {yield return '0'; yield break;}
    if(i<0) { i = -i; neg = true;}
    while (i!=0)
    {
        char digit = (char)(i % 10 + '0');
        i = i / 10;
        yield return digit;
    }
    if(neg) yield return '-';

    yield break;
}

