Sql server real datatype, what is the C# equivalen

2020-05-24 19:13发布

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

标签: c# sql-server
7条回答
Emotional °昔
2楼-- · 2020-05-24 19:33

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

查看更多
戒情不戒烟
3楼-- · 2020-05-24 19:38

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

Double gets the exact value with out Rounding

查看更多
爷的心禁止访问
4楼-- · 2020-05-24 19:41

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.

查看更多
5楼-- · 2020-05-24 19:49

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

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

查看更多
别忘想泡老子
6楼-- · 2020-05-24 19:50

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.

查看更多
混吃等死
7楼-- · 2020-05-24 19:55

it is a Single

see here for more info on SQL Server to .Net DataTypes

查看更多
登录 后发表回答