1

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.

webworm
  • 10,587
  • 33
  • 120
  • 217

4 Answers4

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
2

From here, Nullable appllies to:

.NET Core
2.2 2.1 2.0 1.1 1.0

.NET Framework
4.8 4.7.2 4.7.1 4.7 4.6.2 4.6.1 4.6 4.5.2 4.5.1 4.5 4.0 3.5 3.0 2.0

.NET Standard
2.0 1.6 1.5 1.4 1.3 1.2 1.1 1.0

Xamarin.Android
7.1

Xamarin.iOS
10.8

Xamarin.Mac
3.0
Yurii N.
  • 5,455
  • 12
  • 42
  • 66
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