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

C#Sql Server

C# Problem Overview


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

C# Solutions


Solution 1 - C#

it is a Single

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

Solution 2 - C#

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.

Solution 3 - C#

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

Double gets the exact value with out Rounding

Solution 4 - C#

The answer is Single. If you use double and your SQL field is type real it will error out. I tested this myself and confirmed.

Solution 5 - C#

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

Solution 6 - C#

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

Solution 7 - C#

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnonymousCowView Question on Stackoverflow
Solution 1 - C#YonahWView Answer on Stackoverflow
Solution 2 - C#msbyuvaView Answer on Stackoverflow
Solution 3 - C#msbyuvaView Answer on Stackoverflow
Solution 4 - C#GuzumbaView Answer on Stackoverflow
Solution 5 - C#prisznitzView Answer on Stackoverflow
Solution 6 - C#Aman GView Answer on Stackoverflow
Solution 7 - C#George NelsonView Answer on Stackoverflow