且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

输入字符串格式不正确。如何解决?

更新时间:2023-09-13 14:53:22

希望txtquantity,price,totalPrice是多变的

hope txtquantity,price,totalPrice are variabeles
int quantity = int.Parse(txtquantity);
    float price =float.Parse(price);
    float totalprice = float.Parse(totalPrice);


您可能意味着以下内容(其中价格 totalprice txtquantity 是对象):

You probably mean the following (where price, totalprice and txtquantity are objects):
protected void totalprice()
    {
        int quantity = int.Parse(txtquantity.Text);
     float price =float.Parse(price);
     float totalprice = float.Parse(totalPrice);
     totalprice=quantity * price;
}


您需要在C#中学习类型转换。看看这些:



http: //msdn.microsoft.com/en-us/library/ms173105.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/ms173105%28v=vs.80%29.aspx [ ^ ]



希望它有所帮助:)
You need to learn the Type casting in C#. Have a look at these:

http://msdn.microsoft.com/en-us/library/ms173105.aspx[^]

http://msdn.microsoft.com/en-us/library/ms173105%28v=vs.80%29.aspx[^]

hope it helps :)