My C# code is being run in a older version of C# (4.0.30319.34209) than in my own development environment. I am wondering if my usage of nullable types will work on this older version of C#. Does anyone know what version of C# nullable types were introduced in? My "Google-fu" came up with nothing.
Asked
Active
Viewed 829 times
1
-
`C# 2.0` i believe. – Ousmane D. Dec 14 '18 at 14:00
-
This is not the C# (language) version you provided. – dymanoid Dec 14 '18 at 14:00
-
2Dont you compile your code against the version you need to target? – Magnus Dec 14 '18 at 14:00
-
https://stackoverflow.com/a/247623/4187549 – Furkan Kambay Dec 14 '18 at 14:01
-
C# 2.0: http://www.tutorialsteacher.com/csharp/csharp-nullable-types – Jim Mischel Dec 14 '18 at 14:01
-
2side note: you need to be *very* clear in your nomenclature - the C# version and the .NET version *are not strongly linked* - the title asks about the .NET version, but the body asks about the language version; these *need not be related* – Marc Gravell Dec 14 '18 at 14:03
-
Thanks for correcting me. The 4.0.30319.34209 refers to the compiler version. – webworm Dec 14 '18 at 14:04
-
I am looking to see what version of the C# compiler my code needs to target to support nullable types – webworm Dec 14 '18 at 14:11
4 Answers
6
Nullable types are §19.5 in the C# 2.0 specification, so: .NET 2.0 and C# 2.0 (it can't have been earlier, as it depends on "generics", which is definitely 2.0)

Marc Gravell
- 1,026,079
- 266
- 2,566
- 2,900
0
C# 2.0 introduced nullable types that allow you to assign null to value type variables. You can declare nullable types using Nullable where T is a type.
Copied from here: http://www.tutorialsteacher.com/csharp/csharp-nullable-types

andreasnico
- 1,478
- 14
- 23
0
Here is a history of C# versions: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history It states that nullable types were introduced in C# v2.0. Hope it helps.

w0ns88
- 344
- 2
- 9
- 28