无法将类型“十进制"隐式转换为“字符串" [英] Cannot implicitly convert type 'decimal' to 'string'

查看:96
本文介绍了无法将类型“十进制"隐式转换为“字符串"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建的购物车中有此代码,但收到标题中显示的错误.此行中显示该错误:

I have this code in a shopping cart I am creating but I am receiving the error shown in the title.The error is showing up on this line:

推荐答案

只需调用ToString即可获取十进制值的字符串表示形式:

Just call ToString to get a string representation of the decimal value:

order.Total = orderTotal.ToString("G");

尽管我不明白为什么将成员Total存储为string而不存储为decimal.

Although I don't see why you would store the member Total as a string and not as a decimal too.

这篇关于无法将类型“十进制"隐式转换为“字符串"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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