| |

VerySource

 Forgot password?
 Register
Search
View: 722|Reply: 5

Questions about type conversion and retaining two digits after the decimal point

[Copy link]

3

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-19 11:00:02
| Show all posts |Read mode
How can I keep the two digits after the decimal point from the recordset?
Response.Write (rs ("test"). Value)
The output is
1.36894117647059
How can I keep the two digits after the decimal point?
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-1-27 23:18:01
| Show all posts
double k = 345464.141592653589;
            string a = k.ToString (". ##");
            Console.Write ("{0}", a);
            Console.ReadLine ();
Reply

Use magic Report

3

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-28 13:18:01
| Show all posts
What I want is 1.37
How to use rs ("test"). Value conversion?
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-1-29 16:00:01
| Show all posts
string str = rs ("test"). value;
str.Format ();
String.Format () in detail in MSDN
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-1-29 16:54:01
| Show all posts
ms-help: //MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.chs/cpref2/html/M_System_String_Format_1_af0ddb68.htm
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-2 15:09:01
| Show all posts
double k = 345464.141592653589
string a = Convert.ToString (decimal.Round (k, 2))
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list