简体   繁体   English

C# Winform 文本框数值

[英]C# Winform Textbox Numeric Value

In my SQL database, I have a table在我的 SQL 数据库中,我有一个表

(Product)
(
  Item nvarchar(50),
  Price real
)

in my C# winform application, I have a class object of this table在我的 C# winform 应用程序中,我有这个表的 class object

class Product
{
  string Item;
  double Price;
}

using binding source, I bind the text property of textbox1.text to Product.Item 
and 
textbox2.text to Product.Price. 

data in my table in the database is as follows, 
Item = Item1
Price = 90.53

when the same data is represented in my app and bound to my two textboxes, textbox1.text = Item1 (no issue here) but textbox2.text = 90.529998779296875 instead of 90.53.当我的应用程序中表示相同的数据并绑定到我的两个文本框时,textbox1.text = Item1(这里没有问题)但 textbox2.text = 90.529998779296875 而不是 90.53。

I can't figure out what makes 90.53 in the database represented as 90.529998779296875 on my textbox?我无法弄清楚是什么让数据库中的 90.53 在我的文本框中表示为 90.529998779296875?

using money data type in SQL side solved the issue and now i always get the exact number as saved in the database在 SQL 中使用货币数据类型解决了这个问题,现在我总是得到数据库中保存的确切数字

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM