프로그래밍/Visual C#
String.Format(숫자편)
Dev-Drake
2020. 1. 3. 17:55
반응형
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int Num = 123456;
String strPrint;
strPrint = String.Format("일반 포맷 : {0}", Num);
Console.WriteLine(strPrint);
strPrint = String.Format("우측 정렬 : {0, 10}", Num);
Console.WriteLine(strPrint);
strPrint = String.Format("좌측 정렬 : {0, -10}", Num);
Console.WriteLine(strPrint);
strPrint = String.Format("좌측 정렬 및 콤마 표시 : {0, -20:N0}", Num);
Console.WriteLine(strPrint);
strPrint = String.Format("우측 정렬 및 콤마 표시 : {0, 20:N0}", Num);
Console.WriteLine(strPrint);
Console.WriteLine("");
}
}
}
결과
반응형