Sql server 真实数据类型,C# 等价物是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/129560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 14:53:08  来源:igfitidea点击:

Sql server real datatype, what is the C# equivalent?

提问by

What is the C# equivalent to the sql server 2005 real type?

什么是 C# 相当于 sql server 2005 real 类型?

回答by YonahW

it is a Single

这是一个单身

see herefor more info on SQL Server to .Net DataTypes

有关 SQL Server 到 .Net DataTypes 的更多信息,请参见此处

回答by msbyuva

Single is not the correct answer as it rounds the decimal part.. For instance 2.0799999 will be converted to 2.08. If there are no constraints regarding the rounding then it should be good.

Single 不是正确答案,因为它四舍五入小数部分。例如,2.0799999 将被转换为 2.08。如果没有关于舍入的限制,那么它应该是好的。

回答by msbyuva

Double can be used as the .NET Equivalent Datatype for Real Datatype of SQL Server

Double 可用作 SQL Server 的 Real 数据类型的 .NET 等效数据类型

Double gets the exact value with out Rounding

Double 获得不四舍五入的精确值

回答by prisznitz

in my project (acces -> firebird and ms sql -> c#) is real defined like single precission float point number...so I used float and everything is OK

在我的项目中(acces -> firebird 和 ms sql -> c#)是像单精度浮点数一样真正定义的......所以我使用了 float 并且一切正常

回答by Guzumba

The answer is float. If you try to use double as the type in the code but your field type in the database is real it will errors out. I just tested this myself and confirmed it errors with double.

答案是浮动。如果您尝试在代码中使用 double 作为类型,但您在数据库中的字段类型是真实的,则会出错。我只是自己测试了这个,并用双重确认了它的错误。

回答by Aman G

Its Equivalent is Single. Single is A floating point number within the range of -3.40E +38 through 3.40E +38.

它的等效项是Single。Single 是 -3.40E +38 到 3.40E +38 范围内的浮点数。

Here is the latest from MSDN describes all SqlDbType and C# Equivalents

这是来自 MSDN 的最新描述所有 SqlDbType 和 C# 等效项

回答by George Nelson

the answer is Singleorfloat. (depending on style.) this is like the difference between Stringand string[source: ReSharper code suggestion "use type keyword" when using Single. it suggested using float.

答案是Singlefloat。(取决于样式。)这就像Stringstring[来源:ReSharper 代码建议在使用Single. 它建议使用float.