输入字符串格式不正确。如何解决? [英] Input string was not in a correct format.how to solve?

查看:103
本文介绍了输入字符串格式不正确。如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道?



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



Can anyone know?

Input string was not in a correct format.how to solve?

protected void totalprice()
    {
        int quantity = int.Parse("txtquantity");
     float price =float.Parse("price");
     float totalprice = float.Parse("totalPrice");
     totalprice=quantity * price;
}

推荐答案

希望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 :)


这篇关于输入字符串格式不正确。如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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