错误CS0029无法将类型'string'隐式转换为'decimal'

时间:2016-01-29 16:48:28

标签: c# visual-studio-2015

namespace FitoStore
{
    public partial class FitoStore : Form
    {
        private Dyqan dyqan = new Dyqan();

        public FitoStore()
        {
            InitializeComponent();
            SetupData();
        }
        private void SetupData()

        {

            dyqan.Shitesit.Add(new Shites { Emeri = "Kujtim", Mbiemeri = "Arishta" });
            dyqan.Shitesit.Add(new Shites { Emeri = "Zaim", Mbiemeri = "Sherbela" });
            dyqan.Produkte.Add(new Produkt {Lloji = "Dap",Kilogram ="25",Cmimi="2.500"});
            dyqan.Produkte.Add(new Produkt {Lloji = "Nitrat",Kilogram="50",Cmimi="2.500"});
        }

    }
 }

1 个答案:

答案 0 :(得分:0)

尝试

        dyqan.Shitesit.Add(new Shites { Emeri = "Kujtim", Mbiemeri = "Arishta" });
        dyqan.Shitesit.Add(new Shites { Emeri = "Zaim", Mbiemeri = "Sherbela" });
        dyqan.Produkte.Add(new Produkt {Lloji = "Dap",Kilogram =25M,Cmimi=2.500M});
        dyqan.Produkte.Add(new Produkt {Lloji = "Nitrat",Kilogram=50M,Cmimi=2.500M});

其中25M means小数值为25。

我也把它做到Cmimi,因为它看起来应该是小数。您可能需要根据其中的类型进行更改。