[C#] string format specifiers.

Format Specifier

Description

C or c

Formats the string as currency. Precedes the number with an appropriate currency symbol ($ in the US). Separates digits with an appropriate separator character (comma in the US) and sets the number of decimal places to two by default.

D or d

Formats the string as a decimal. Displays number as an integer.

N or n

Formats the string with commas and a default of two decimal places.

E or e

Formats the number using scientific notation with a default of six decimal places.

F or f

Formats the string with a fixed number of decimal places (two by default).

G or g

General. Formats the number normally with decimal places or using scientific notation, depending on context. If a format item does not contain a format specifier, format G is assumed implicitly.

X or x

Formats the string as hexadecimal.

Reference: Visual C#® 2005: How to Program, Second Edition

Advertisements
  1. #1 by Ting Yu on November 20, 2007 - 4:09 pm

    進來逛一下我傻眼了…
    這是啥@qte$%#$%$#%#$

  2. #2 by Richard on November 29, 2007 - 3:23 pm

    這個是可以指定變數型態的參數…
    有興趣的話, 可以先讀一下 "變數" 是什麼東西…
    再來才比較容易了解這張表的用途… ^_^
     
    Reference: Visual C#® 2005: How to Program, Second Edition

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: