c#如何让一串未知的数字每隔3位显示逗号

来源:百度知道 编辑:UC知道 时间:2024/06/25 12:58:19
用WPF写的,有一个数字S,是需要前面的数字加起来的,所以有未知很多位。
我需要每隔三位加一个逗号。比如67892542.4647,最好可以用S.Indexof,S.Length,S.Insert这些写出来。

下边是我写的以67892542.4647为值进行的运算你可以随便改它的值。

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

namespace 字符串分割
{
class s
{
public string c;
public int value(string x)
{
c = x;
return c.Length;
}
public string substring(int a)
{
return c.Substring(a);
}
public string substring(int a, int b)
{
return c.Substring(a,b);
}
}
class Program
{
static void Main(string[] args)
{
s i = new s();
double j = 67892542.4647;
string n = Convert.ToString(j);
int b;
b = i.value(n);
int m = 0;
int k = b / 3;
string l;
Console.WriteLine("