我想从文本框中的内容中休息一个百分比 [英] i want to rest a percentage from the content in the textboxes

查看:65
本文介绍了我想从文本框中的内容中休息一个百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们



i需要从两个文本框的答案中休息一个百分比,但我真的不知道怎么样,我这样做只是给我一个从家庭作业的方式错误,这就是我所做的路线; textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text)* Convert.ToDouble(textBox2.Text) - 13%); 下划线中的部分给我一个无效的表达式术语,我希望你能提供帮助,谢谢你,祝你有愉快的一天! :D

hi guys

i need to rest a percentage from the answer of two textboxes but i realy don't know how, the way i do it just give me an error by the way its from a homework and this is the line i've made; textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox2.Text) - 13%); the part in the underline is given me an invalid expression term, i hope you may help, thank you and have a nice day! :D

推荐答案

textBox3.Text = Convert.ToString(Convert.ToDouble(textBox1.Text) * Convert.ToDouble(textBox2.Text) - 13%);



问题是你使用13%,因为它是一个数字,这不是!

当你谈论百分比它总是一定比例的东西,所以你必须看看你想要计算这个百分比的数字......

如果你有一个数字 a 你得到这个数字的13%,比如


The problem is that you use 13% as it was a number, which is not!
When you talking about percentage it is always a percentage of something, so you have to see from what number you want to compute that percentage...
Like if you have a number a you get 13% of that number like

(a/100)*13



这将为您提供13%的 a ...

因此,请检查您的作业,看看您应该做些什么...


That will gives you the 13% of a...
So review your assignment and see what you should do...


模运算符 [ ^ ]在c#中与百分比无关。

所以你要么减去13或者0.13但是如果你需要在结尾添加一个%符号,你应该使用String.Format,或者在将它转换为字符串后添加%字符。
% is the modulo operator[^] in c# and has nothing to do with percentage.
So you either substract 13 or 0.13 but if you need to add a % sign at the end, you should use String.Format, or simply add "%" character after converting it to string.


这篇关于我想从文本框中的内容中休息一个百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆