C# char calculation problem
<p>Im trying to do a permutation. of five in this case, so 5,4,3,2,1 . Eventually I want it to permute up to 100 which can be stored in my intX class. the calculation is fine, but I want to add up all individual numbers of the output, using the script below.</p>

<p>so 5! = 5x4x3x2x1 = 120 ----> 1+2+0 = 3. BUT My script below gives the output 147:</p>

<pre><code>120
1
2
0
147
</code></pre>

<p>What am I doing wrong? I allready tried all converts, I started with just using the string[pointer] thingy, I tried different arrays etc.. but it all keeps coming up with 147. Is it some kind of representation thing?</p>

<pre><code>    static void Main(string[] args)
    {
        IntX total=1;
        IntX totalsum = 0;
        int perm = 5;
        for (int i = perm; i &gt; 0; i--)
        {
            total = total * i;
        }
        Console.WriteLine(total);

        string answerstring = Convert.ToString(total);
        char[] answerArray = answerstring.ToArray();
        for (int x = 0; x &lt; answerArray.Length; x++)
        {
            totalsum += Convert.ToInt32(answerArray[x]);
            Console.WriteLine(answerArray[x]);
        }
        Console.WriteLine(totalsum);
    }
</code></pre>
