C急剧代码问题请快速帮助 [英] C sharp code problem please help fast

查看:66
本文介绍了C急剧代码问题请快速帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误CS1503参数1:无法从'System.Windows.Forms.TextBox'转换为'string'



我尝试过:



private void fullTotalButton_Click(object sender,EventArgs e)

{

const decimal TAXRATE = 0.12 m;

十进制val1 = decimal.Parse(MealCost.Text);

十进制结果= val1 * TAXRATE;

taxAmount.Text =结果.ToString(C);

十进制结果= val1 +结果;

fullTaxLabel.Text = outcome.ToString(C);

decimal val7 = decimal.Parse(tipCalculate);

十进制结束= val7 +结果;

tipamountBox.Text = ending.ToString(C);

Error CS1503 Argument 1: cannot convert from 'System.Windows.Forms.TextBox' to 'string'

What I have tried:

private void fullTotalButton_Click(object sender, EventArgs e)
{
const decimal TAXRATE = 0.12m;
decimal val1 = decimal.Parse(MealCost.Text);
decimal result = val1 * TAXRATE;
taxAmount.Text = result.ToString("C");
decimal outcome = val1 + result;
fullTaxLabel.Text = outcome.ToString("C");
decimal val7 = decimal.Parse(tipCalculate);
decimal ending = val7 + outcome;
tipamountBox.Text = ending.ToString("C");

推荐答案

看看这一行:

Look at this line:
decimal val7 = decimal.Parse(tipCalculate);



这需要是一个字符串参数 - 所以请参阅文本属性:




That needs to be a string parameter - so reference the Text property:

decimal val7 = decimal.Parse(tipCalculate.Text);



将来,如果您查看Visual Studio中的错误消息,可以双击它,然后您将直接带到错误行。


In future, if you look at the error message in Visual Studio, you can double click it, and you will be taken to the line with the error directly.


这篇关于C急剧代码问题请快速帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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