Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用十进制数据类型_C#_Sql Server_Type Conversion - Fatal编程技术网

C# 如何使用十进制数据类型

C# 如何使用十进制数据类型,c#,sql-server,type-conversion,C#,Sql Server,Type Conversion,我想得到我所给予的价值 我使用的数据类型是C#中的decimal,SQL Server中的numeric(18,8) 以下是C#中的声明: 但是,当我提供的值为13.0777545125时,我得到的值为13.07000000 我认为有一个简单的解决办法,但我遗漏了一些东西。请任何人帮助我您可以尝试在模型属性中使用DisplayFormat [DisplayFormat(DataFormatString = "{0:0.##}")] public decimal Lat { get; set

我想得到我所给予的价值

我使用的数据类型是C#中的
decimal
,SQL Server中的
numeric(18,8)

以下是C#中的声明:

但是,当我提供的值为
13.0777545125
时,我得到的值为
13.07000000


我认为有一个简单的解决办法,但我遗漏了一些东西。请任何人帮助我

您可以尝试在模型属性中使用
DisplayFormat

 [DisplayFormat(DataFormatString = "{0:0.##}")] 
 public decimal Lat { get; set; }
有关详细信息,请查看此链接:
首先,我想把它存储在数据库中,而不是显示。ShanMuGMi知道,但是你把它存储到数据库中使用,上面将输出一个高达2个小数点的数字。你设置为Par你的要求,谢谢你,我用它,我得到相同的结果。我想这样储存13.55555。
 [DisplayFormat(DataFormatString = "{0:0.##}")] 
 public decimal Lat { get; set; }