c#大数字后缀

c#大数字后缀,c#,formatting,C#,Formatting,我正在寻找一个库或一种方法来创建一个非常大的数字作为像这样的后缀-但是对于c#。有人能告诉我我应该找什么吗,因为我没有为c#找到这样的东西 试着跟随 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication163 { class Program { static void Main(stri

我正在寻找一个库或一种方法来创建一个非常大的数字作为像这样的后缀-但是对于c#。有人能告诉我我应该找什么吗,因为我没有为c#找到这样的东西

试着跟随

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication163
{
    class Program
    {
        static void Main(string[] args)
        {
            SuffixAlphabetic[] numbers = { 
                   new SuffixAlphabetic() {number = 1000, format = "1e3"},
                   new SuffixAlphabetic() {number = 100000, format = "1e5"},
                   new SuffixAlphabetic() {number = 1000000, format = "1e6"},
                   new SuffixAlphabetic() {number = 1000000000, format = "1e9"},
                   new SuffixAlphabetic() {number = 1000000000000, format = "1e12"},
                    new SuffixAlphabetic() {number = 1000000000000000, format = "1e15"},
                    new SuffixAlphabetic() {number = 1000000000000000000, format = "1e18"}
                                         };

            foreach (SuffixAlphabetic number in numbers)
            {
                Console.WriteLine(SuffixAlphabetic.ToString(number));
            }
            Console.ReadLine();
        }
    }
    public class SuffixAlphabetic
    {
        static string[] standardSuffix = { "", "K", "M", "B", "T" };
        public long number { get; set; }
        public string format { get; set; }
        public static string ToString(SuffixAlphabetic number)
        {
            double temp = 0;
            int exp = int.Parse(number.format.Replace("1e", ""));
            int thousand = exp / 3;

            string results = "";

            if (thousand <= 1)
            {
                return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0,0}", number.number);  
            }

            temp = number.number / Math.Pow(10, exp);
            results = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:#,##0.00}", temp);
            if (thousand <= 4)
            {
                results += standardSuffix[thousand];
                return results;
            }
            else
            {
                char letter = (char)((thousand - 5) + ((byte)'a'));
                results += "a" + letter;
                return results;
            }
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
命名空间控制台应用程序163
{
班级计划
{
静态void Main(字符串[]参数)
{
后缀字母[]数字={
新的SuffixAlphabetic(){number=1000,format=“1e3”},
新的SuffixAlphabetic(){number=100000,format=“1e5”},
新的SuffixAlphabetic(){number=1000000,format=“1e6”},
新的SuffixAlphabetic(){number=100000000,format=“1e9”},
新的SuffixAlphabetic(){number=1000000000000,format=“1e12”},
新的SuffixAlphabetic(){number=10000000000000,format=“1e15”},
新的SuffixAlphabetic(){number=10000000000000000,format=“1e18”}
};
foreach(数字中的后缀字母数字)
{
Console.WriteLine(SuffixAlphabetic.ToString(number));
}
Console.ReadLine();
}
}
公共类后缀
{
静态字符串[]standardSuffix={”、“K”、“M”、“B”、“T”};
公共长编号{get;set;}
公共字符串格式{get;set;}
公共静态字符串ToString(后缀字母编号)
{
双温=0;
int exp=int.Parse(number.format.Replace(“1e”和“”);
整数千=exp/3;
字符串结果=”;

如果(非常感谢,它确实输出了我问题中所显示的内容。但我猜它仅限于某个数字,因为如果我想输出像1.00zz这样的东西,它将不适用于当前类型,您知道如何将其扩展到适用于更大的数字吗?即使使用bigint也不足够。有没有办法转换一个极端的值在很久以前的工作中,我们的一位科学家建立了一个指数运算器,他用字节数组进行数学运算。他正在研究生成大素数。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication163
{
    class Program
    {
        static void Main(string[] args)
        {
            SuffixAlphabetic[] numbers = { 
                   new SuffixAlphabetic() {number = 1000, format = "1e3"},
                   new SuffixAlphabetic() {number = 100000, format = "1e5"},
                   new SuffixAlphabetic() {number = 1000000, format = "1e6"},
                   new SuffixAlphabetic() {number = 1000000000, format = "1e9"},
                   new SuffixAlphabetic() {number = 1000000000000, format = "1e12"},
                    new SuffixAlphabetic() {number = 1000000000000000, format = "1e15"},
                    new SuffixAlphabetic() {number = 1000000000000000000, format = "1e18"}
                                         };

            foreach (SuffixAlphabetic number in numbers)
            {
                Console.WriteLine(SuffixAlphabetic.ToString(number));
            }
            Console.ReadLine();
        }
    }
    public class SuffixAlphabetic
    {
        static string[] standardSuffix = { "", "K", "M", "B", "T" };
        public long number { get; set; }
        public string format { get; set; }
        public static string ToString(SuffixAlphabetic number)
        {
            double temp = 0;
            int exp = int.Parse(number.format.Replace("1e", ""));
            int thousand = exp / 3;

            string results = "";

            if (thousand <= 1)
            {
                return String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:0,0}", number.number);  
            }

            temp = number.number / Math.Pow(10, exp);
            results = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:#,##0.00}", temp);
            if (thousand <= 4)
            {
                results += standardSuffix[thousand];
                return results;
            }
            else
            {
                char letter = (char)((thousand - 5) + ((byte)'a'));
                results += "a" + letter;
                return results;
            }
        }
    }
}