简体   繁体   中英

Which version of the C# compiler introduced nullable types?

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.

可空类型在C#2.0规范中为§19.5,因此:.NET 2.0和C#2.0(不能早于此,因为它取决于“泛型”,绝对是2.0)

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

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

Here is a history of C# versions: https://docs.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM