string - Value of type 'String' cannot be converted to System.Windows.Forms.Label
问题描述
I'm a bit of a noob. When I try to build my solution I get this single error and I don't know what to do to fix it.
'Calculate and display cost estimate
decCostEstimate = decFeet * decCostPerFoot
**lblCostEstimate = decCostEstimate.ToString("C")**
I'm not sure what to do. Please help me.
解决方案
标签是 type 中的一个对象 Label
。无法将 Typeint
或string
等中的对象写入标签对象。
要使标签显示您的结果,只需将结果放入标签的文本属性中:
lblCostEstimate.Text = decCostEstimate.ToString("C")
推荐阅读
- java - windows下如何通过Java更新保存导入的CA证书?
- ios - 根据以前的位置绘制折线,以跟踪用户路径
- sql - 如何加快 FULL OUTER JOIN
- html - 使用 flexbox 对齐 3 个元素
- node.js - 将数据包发送到源专用服务器
- django - Django 频道 - 聊天
- django-forms - 向 Django 添加文本区域的正确方法是什么?
- wkhtmltopdf - Wkhtmltopdf,找不到二进制文件
- java - Java ProcessBuilder 从 Linux 终端命令获取输出
- javascript - 为什么picturesArray总是空的?