Tostring record for your convenience, and tostring record viewing

Source: Internet
Author: User

Tostring record for your convenience, and tostring record viewing

C

Currency

2.5.ToString ("C ")

¥2.50

D

Decimal number

25. ToString ("D5 ")

00025

E

Scientific type

25000. ToString ("E ")

2.500000E + 005

F

Fixed Point

25. ToString ("F2 ")

25.00

G

General

2.5.ToString ("G ")

2.5

N

Number

2500000. ToString ("N ")

2,500,000.00

X

Hexadecimal

255. ToString ("X ")

FF

Number Format 0.00

Number, which can be multiple 0

255. ToString ("0.00 ")

255.00

 

Format

Output

Example

Year

Y

7

String yy = DateTime. Now. ToString ("y-MM ")
Yy = "7-05"

Yy

07

String yy = DateTime. Now. ToString ("yy-MM ")
Yy = "07-05"

Yyy or more y

1984

String yy = DateTime. Now. ToString ("yyyy ");
Yy = "2007"

Month

M

5.

String mon = DateTime. Parse ("1984-05-09") ToString ("yyyy-M ")
Mon = "1984-5"

MM

05.

String mon = DateTime. Parse ("1984-05-09") ToString ("MM ")
Mon = "05"

MMM

If it is a Chinese version of the operating system, the output will be: May.
For an English operating system, enter the abbreviation of the first three letters of the Month: May

String mon = DateTime. Parse ("2006-07-01"). ToString ("MMM ")
English version: Jul
Chinese version Operating System: July

MMMM or more M

If it is a Chinese version of the operating system, the output will be: May.
For an English operating system, enter the full number of months.

String mon = DateTime. Parse ("2006-07-01"). ToString ("MMM ")
English version: July
Chinese version Operating System: July

Date or week

D

9

String dd = DateTime. Parse ("1984-05-09") ToString ("d ")
Dd = "9"

Dd

09

String dd = DateTime. Parse ("1984-05-09") ToString ("dd ")
Dd = "09"

Ddd

For a Chinese operating system, the week, for example, Wednesday, is displayed ..
For an English operating system, the abbreviation of the week is output:
Wed

String dd = DateTime. Parse ("2006-07-01"). ToString ("ddd ")
English version: Wed
Chinese operating system: Wednesday

Dddd or more d

For a Chinese operating system, the week, for example, Wednesday, is displayed ..
For an English operating system, the week is output, as shown in figure
Wednesday

String dd = DateTime. Parse ("2006-07-01"). ToString ("dddd ")
English version: Wednesday
Chinese operating system: Wednesday

Hours

H

Hour range: 1-12

String hh = DateTime. Now. ToString ("h ");
Hh = 8

Hh or more h

Hour range: 1-12

String hh = DateTime. Now. ToString ("hh ");
Hh = 08

H

Hour range: 0-23

String hh = DateTime. Now. ToString ("yyyy-H ");
Hh = 2006-8

HH or more H

Hour range: 0-23

String hh = DateTime. Now. ToString ("yyyy-HH ");
Hh = 2006-08
String hh = DateTime. Pare ("18:00:00"). ToString ("yyyy-HH ");
Hh = 2006-18

Minutes

M

6

String mm = DateTime. Now. ToString ("yyyy-MM-dd-m ");
Mm = "2006-07-01-6 ";

Mm or more m

06

String mm = DateTime. Now. ToString ("yyyy-MM-dd-mm ");
Mm = "2006-07-01-06 ";

Seconds

S

6

String mm = DateTime. Now. ToString ("yyyy-MM-dd-s ");
Mm = "2006-07-01-6 ";

Ss or more s

06

String mm = DateTime. Now. ToString ("yyyy-MM-dd-ss ");
Mm = "2006-07-01-06 ";

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.