本文介绍了在C#非常大数字的数字之和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#如何在文本框4534534534543533453432432434324324324234中为非常大的数字进行数字求和,结果在其他文本框中显示为140/14 / 5.如果数字很小,则为ex。 45345345343结果文本框显示为43 / 7.更小的ex.45显示为9.请任何身体帮助我的项目紧急。

这不适合我的学校/大学项目...对不起英语不好...

到目前为止完成的代码...



C# How to do Sum of Digits for very big number in a textbox 4534534534543533453432432434324324324234 and result display in other text box as 140 / 14 / 5. if number is small ex. 45345345343 result text box display as 43 / 7. Even smaller ex.45 display as 9. Please any body help it is urgent for my project.
It is not for my school/college project ... sorry for bad English...
Code done so far...

 public long DigitSum(String BigNumberStr,int len)
    {
        int total = 0;
        int s=BigNumberStr.Length;

        if (len == 10)
        {
            for (int i = 0; i < s; i++)
                total += int.Parse(Convert.ToString(BigNumberStr[i]));
        }
        else if (len == 100)
        {
            for (int i = 0; i < s; i++)
                total += int.Parse(Convert.ToString(BigNumberStr[i]));
        }

                return total;
 }
fun.DigitSum(TextBox2.Text + TextBox10.Text, 100);
fun.DigitSum(TextBox2.Text + TextBox10.Text, 1000);







但它不起作用请帮助某人......结果显示如下格式..

2132 = 8

213245 = 17/8

21324545454454545365756756 = 116/17/8




But it's not working please help somebody... Result display in following format..
2132 = 8
213245 = 17 / 8
21324545454454545365756756 = 116 / 17 / 8

推荐答案




这篇关于在C#非常大数字的数字之和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:45