无法将类型“十进制"隐式转换为“字符串"

无法将类型“十进制

问题描述:

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

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.