반응형
기초를 튼튼히 하면 삽질을 줄일수 있어요!
You based foundation when the shoveling to reduce.
Result :
Code :
static void Main(string[] args)
{
Console.WriteLine("123456789012345678901234567890123456789012");// 총길이 42칸
Console.WriteLine(String.Format("{0,42}", "test")); //우측정렬
Console.WriteLine(String.Format("{0,-42}", "te13123123st")); //좌측정렬
Console.WriteLine(String.Format("{0}", "1").PadLeft(42 - (21 - ("1".Length / 2))));// 가운데정렬
Console.WriteLine(String.Format("{0}", "123").PadLeft(42 - (21 - ("123".Length / 2))));
Console.WriteLine(String.Format("{0}", "12345").PadLeft(42 - (21 - ("12345".Length / 2))));
Console.WriteLine(String.Format("{0}", "1234567890").PadLeft(42 - (21 - ("1234567890".Length / 2))));
Console.WriteLine(String.Format("{0}", "123451234567890").PadLeft(42 -
(21 - ("123451234567890".Length / 2))));
Console.WriteLine(String.Format("{0}", "12345678901234567890").PadLeft(42 -
(21 - ("12345678901234567890".Length / 2))));
Console.WriteLine("123456789012345678901234567890123456789012");
}
'.NET > C# Basic' 카테고리의 다른 글
C# CallerMemberNameAttribute Class 소개 (0) | 2016.02.29 |
---|---|
C# Custom Sort Null 널값이 제일 아래로 IComparer IComparable (2) | 2013.08.23 |
DLL Ressource 에서 BitmapImage 불러오기 Method (1) | 2013.01.11 |
Visual Studio 2005의 원격 디버깅 설정(http://www.hoonsbara.com/) (1) | 2010.06.14 |
[C#] char[] + char[] = char[]?? | char[] Merge (0) | 2010.02.09 |
[C#] Thread를 정복해 보자 (0) | 2010.02.06 |
사용예) StringCollection 과 string[] int[] converterMethod (0) | 2010.02.02 |
[C#] 하드시리얼넘버, 외부IP, 내부IP, DNS , NetBios, GUID 그위드 , 클릭온스 버전, 외부아이피 내부아이피 구하기 메서드 (0) | 2010.01.28 |