Home
C#
Single and Double Types
Updated Sep 7, 2023
Dot Net Perls
Single, Double. In C# programming, we hear about float and double. But these types are syntactic sugar—we can refer to them as Single and Double.
Some type notes. They have no differences from the common types they are aliased to. In C# programming, we often hear about a Double, but less commonly about a Single.
float
double
Alias chart. To understand Single and Double, we can simply remember that float is the same thing as Single. One type is aliased to another at the language level.
float -> Single double -> Double
An example. This program creates an instance of the Single and Double types. It then prints their types to the console window. Then it does the same thing for the float and double types.
And This shows us that the Single type is the same as the float type, and the Double type is the same as the (lowercase) double type.
using System; { Single a = 1; Double b = 1; Console.WriteLine(a.GetType()); Console.WriteLine(b.GetType()); } { float a = 1; double b = 1; Console.WriteLine(a.GetType()); Console.WriteLine(b.GetType()); }
System.Single System.Double System.Single System.Double
A discussion. The Single and Double types are precisely equivalent to the float and double types. It is more conventional for C-style language programmers to use float than Single.
Also Code written with float is less likely to confuse other programmers who might then introduce bugs.
A summary. This article doesn't provide useful examples for Single or Double. It demonstrates that these types are precisely equivalent to the float and double types.
Dot Net Perls is a collection of pages with code examples, which are updated to stay current. Programming is an art, and it can be learned from examples.
Donate to this site to help offset the costs of running the server. Sites like this will cease to exist if there is no financial support for them.
Sam Allen is passionate about computer languages, and he maintains 100% of the material available on this website. He hopes it makes the world a nicer place.
This page was last updated on Sep 7, 2023 (edit).
Home
Changes
© 2007-2025 Sam Allen