투케이2K

53. (C#/NET) [Mac Os] [문법] String.Format 사용해 int 데이터를 3자릿수 콤마 형식 출력 실시 본문

C샵 (NET)

53. (C#/NET) [Mac Os] [문법] String.Format 사용해 int 데이터를 3자릿수 콤마 형식 출력 실시

투케이2K 2024. 3. 16. 03:03
반응형

[개발 환경 설정]

개발 언어 : C# / NET

 

[소스 코드]

using System;
using System.Collections;
using System.Data;

namespace testProject {


    // [프로그램 동작 클래스]
    class Program {

        static void Main(string[] args){
            
            /*
            -------------------------------------------
            [요약 설명]
            -------------------------------------------
            1. String.Format : 특정 데이터 타입에 특정 형식을 지정해 string 문자열로 변경합니다
            -------------------------------------------
            */


            // [변수 선언 실시]
            int intData = 1234567;

            // [3자리 기준 콤마 형식]
            string strData = String.Format("{0:#,###}", intData);

            // [로그 출력 수행]
            Console.WriteLine($"");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"[Main] : [Log]");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"strData : {strData}");
            Console.WriteLine($"------------------------------------------");
            Console.WriteLine($"");

        }

    }

}
 

[결과 출력]

 

 

반응형
Comments