>  기사  >  백엔드 개발  >  C#의 Double 문자열 형식

C#의 Double 문자열 형식

PHPz
PHPz앞으로
2023-09-11 11:29:02772검색

C# 中 Double 的字符串格式

C#의 정적 메서드 String.Format을 사용하여 이중 문자열 형식을 구성합니다.

소수점 세 자리 -

String.Format("{0:0.000}", 987.383);
String.Format("{0:0.000}", 987.38);
String.Format("{0:0.000}", 987.7899);

천 단위 구분 기호 -

String.Format("{0:0,0.0}", 54567.46);
String.Format("{0:0,0}", 54567.46);

형식 문자열 -

using System;

class Demo {

   public static void Main(String[] args) {
      Console.WriteLine("Three decimal places...");
   
      Console.WriteLine( String.Format("{0:0.000}", 987.383));
      Console.WriteLine( String.Format("{0:0.000}", 987.38));
      Console.WriteLine(String.Format("{0:0.000}", 987.7899));
   
      Console.WriteLine("Thousands Separator...");
      Console.WriteLine(String.Format("{0:0,0.0}", 54567.46));
      Console.WriteLine(String.Format("{0:0,0}", 54567.46));
   }
}

위 내용은 C#의 Double 문자열 형식의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제