String.Format 관련하여 MSDN 을 검색하던중..
보기 편하게 정리된 내용이 있었다..
다음 처럼..
물론 링크는 요기..
http://msdn.microsoft.com/ko-kr/library/fht0f5be(VS.85).aspx
enum Color { Yellow = 1, Blue, Green };
static DateTime thisDate = DateTime.Now;
protected void Page_Load(object sender, EventArgs e)
{
string s = "";
Response.Write("Standard Numeric Format Specifiers<br>");
s = String.Format(
"(C) Currency: . . . . . . . . {0:C}<br>" +
"(D) Decimal:. . . . . . . . . {0:D}<br>" +
"(E) Scientific: . . . . . . . {1:E}<br>" +
"(F) Fixed point:. . . . . . . {1:F}<br>" +
"(G) General:. . . . . . . . . {0:G}<br>" +
" (default):. . . . . . . . {0} (default = 'G')<br>" +
"(N) Number: . . . . . . . . . {0:N}<br>" +
"(P) Percent:. . . . . . . . . {1:P}<br>" +
"(R) Round-trip: . . . . . . . {1:R}<br>" +
"(X) Hexadecimal:. . . . . . . {0:X}<br>",
-123, -123.45f);
Response.Write(s);
Response.Write("<hr>");
Response.Write("Standard DateTime Format Specifiers<br>");
s = String.Format(
"(d) Short date: . . . . . . . {0:d}<br>" +
"(D) Long date:. . . . . . . . {0:D}<br>" +
"(t) Short time: . . . . . . . {0:t}<br>" +
"(T) Long time:. . . . . . . . {0:T}<br>" +
"(f) Full date/short time: . . {0:f}<br>" +
"(F) Full date/long time:. . . {0:F}<br>" +
"(g) General date/short time:. {0:g}<br>" +
"(G) General date/long time: . {0:G}<br>" +
" (default):. . . . . . . . {0} (default = 'G')<br>" +
"(M) Month:. . . . . . . . . . {0:M}<br>" +
"(R) RFC1123:. . . . . . . . . {0:R}<br>" +
"(s) Sortable: . . . . . . . . {0:s}<br>" +
"(u) Universal sortable: . . . {0:u} (invariant)<br>" +
"(U) Universal sortable: . . . {0:U}<br>" +
"(Y) Year: . . . . . . . . . . {0:Y}<br>",
thisDate);
Response.Write(s);
Response.Write("<hr>");
Response.Write("Standard Enumeration Format Specifiers<br>");
s = String.Format(
"(G) General:. . . . . . . . . {0:G}<br>" +
" (default):. . . . . . . . {0} (default = 'G')<br>" +
"(F) Flags:. . . . . . . . . . {0:F} (flags or integer)<br>" +
"(D) Decimal number: . . . . . {0:D}<br>" +
"(X) Hexadecimal:. . . . . . . {0:X}<br>",
Color.Green);
Response.Write(s);
}
결과는 이렇게..
보기 편하게 정리된 내용이 있었다..
다음 처럼..
물론 링크는 요기..
http://msdn.microsoft.com/ko-kr/library/fht0f5be(VS.85).aspx
enum Color { Yellow = 1, Blue, Green };
static DateTime thisDate = DateTime.Now;
protected void Page_Load(object sender, EventArgs e)
{
string s = "";
Response.Write("Standard Numeric Format Specifiers<br>");
s = String.Format(
"(C) Currency: . . . . . . . . {0:C}<br>" +
"(D) Decimal:. . . . . . . . . {0:D}<br>" +
"(E) Scientific: . . . . . . . {1:E}<br>" +
"(F) Fixed point:. . . . . . . {1:F}<br>" +
"(G) General:. . . . . . . . . {0:G}<br>" +
" (default):. . . . . . . . {0} (default = 'G')<br>" +
"(N) Number: . . . . . . . . . {0:N}<br>" +
"(P) Percent:. . . . . . . . . {1:P}<br>" +
"(R) Round-trip: . . . . . . . {1:R}<br>" +
"(X) Hexadecimal:. . . . . . . {0:X}<br>",
-123, -123.45f);
Response.Write(s);
Response.Write("<hr>");
Response.Write("Standard DateTime Format Specifiers<br>");
s = String.Format(
"(d) Short date: . . . . . . . {0:d}<br>" +
"(D) Long date:. . . . . . . . {0:D}<br>" +
"(t) Short time: . . . . . . . {0:t}<br>" +
"(T) Long time:. . . . . . . . {0:T}<br>" +
"(f) Full date/short time: . . {0:f}<br>" +
"(F) Full date/long time:. . . {0:F}<br>" +
"(g) General date/short time:. {0:g}<br>" +
"(G) General date/long time: . {0:G}<br>" +
" (default):. . . . . . . . {0} (default = 'G')<br>" +
"(M) Month:. . . . . . . . . . {0:M}<br>" +
"(R) RFC1123:. . . . . . . . . {0:R}<br>" +
"(s) Sortable: . . . . . . . . {0:s}<br>" +
"(u) Universal sortable: . . . {0:u} (invariant)<br>" +
"(U) Universal sortable: . . . {0:U}<br>" +
"(Y) Year: . . . . . . . . . . {0:Y}<br>",
thisDate);
Response.Write(s);
Response.Write("<hr>");
Response.Write("Standard Enumeration Format Specifiers<br>");
s = String.Format(
"(G) General:. . . . . . . . . {0:G}<br>" +
" (default):. . . . . . . . {0} (default = 'G')<br>" +
"(F) Flags:. . . . . . . . . . {0:F} (flags or integer)<br>" +
"(D) Decimal number: . . . . . {0:D}<br>" +
"(X) Hexadecimal:. . . . . . . {0:X}<br>",
Color.Green);
Response.Write(s);
}
결과는 이렇게..