社区
C#
帖子详情
Why I can't Convert this string to Double?
bbwolf
2002-07-13 12:01:07
The string is "12.5%"
but I can't Convert it to 0.125
Who can tell me why?
...全文
96
6
打赏
收藏
Why I can't Convert this string to Double?
The string is "12.5%" but I can't Convert it to 0.125 Who can tell me why?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
forestwind
2002-07-13
打赏
举报
回复
说的对
hbxtx
2002-07-13
打赏
举报
回复
自己写个函数,先从字符串中取出12.5,再除以100。
xdev
2002-07-13
打赏
举报
回复
%不是一个数值字符啊
12.5% 要转换位0.125就可以了
chen_funer
2002-07-13
打赏
举报
回复
关注
bbwolf
2002-07-13
打赏
举报
回复
各位的方法我当然是知道的,只是C#中的System.Globalization.NumberStyles.AllowTrailingSign是允许后缀的,
同时ystem.Globalization.NumberFormatInfo.InvariantInfo.PercentSymbol
表示后缀的许可字符,可以将数字转换为包含System.Globalization.NumberFormatInfo.InvariantInfo.PercentSymbol的string.为什么没有反向的?各位不觉得奇怪么?
zyongcai
2002-07-13
打赏
举报
回复
首先要先取出12.5这个字符串,转化成数字,再除以100即可,代码如下:
string a="12.5%";
a=a.Substring (0,a.Length -1);
double b=Convert.ToDouble (a);
MessageBox.Show (b.ToString ());
Sakemail
The side effect for this is that YOUR app must check if the host is a host name or a IP address, in my app I remove the periods and try to
convert
the result to a float (long integers don‘t work, ...
UE(官方下载)
A question we often see is "I have a lot of blank lines in my file and I don't want to go through and manually delete them. Is there an easier way to do this?" The answer is: yes! Configure FTP Set up...
Using LUA with Visual C++ (Introduction)
For example we can't
convert
a boolean to a
string
: // Push 1 (true) lua_pushboolean(L, 1); // And pop it again as a
string
(s --> NULL) const char *s = lua_pop
string
(L); There are many other ...
Google C++ Style Guide(Google C++编程规范)高清PDF
We do this to keep code simple and to avoid the various common errors and problems that these features can cause. This guide lists these features and explains why their use is restricted. Open-...
au3反编译源码
To copy text or to enlarge the log window
double
click on it. Supported Obfuscators: 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.14 [June 16, 2007]' , 'Jos van der Zande AutoIt3 Source ...
C#
110,571
社区成员
642,565
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章