58

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

2
  • 1
    Voted down because this answer is flawless and it has been on here for 13 days. Commented Oct 6, 2008 at 22:27
  • 9
    Is there a way for the community to accept answers to abandoned questions, other than merely voting for them? Commented Feb 21, 2012 at 18:42

7 Answers 7

87

it is a Single

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

Sign up to request clarification or add additional context in comments.

9 Comments

Why was this answer not accepted? This is not how the community should be working. Too many questions are going weeks with no accepted answer.
Who cares? The author didn't care to bother, but we as the community don't need their blessing to see and influence the "best" answer.
Single looses precision. Double should be a more appropriate candidate.
However I used always double due to precision minor issues. It's correct Single is the exact one but I had some problems with that type.
@Rich float is Single. Same as int being Int32 or long being Int64, it's just a shorthand alias.
|
9

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.

Comments

7

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

Double gets the exact value with out Rounding

2 Comments

The correct type for double data type in .NET Framework is float, you probably may get an excepction in execution time as I'm having at this moment.
@Leonardo - a C# struct 'System.Double' is the same as the intrinsic type 'double', not float as your comment suggests.
5

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.

1 Comment

float in C# = Single, it's just a synonym (like bool and Boolean)
3

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

Comments

3

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.

Comments

1

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

Comments