Created
May 15, 2024 07:44
-
-
Save admir-live/47de306dcc41ee08dd0ddc5d77e14e35 to your computer and use it in GitHub Desktop.
GenericHolderNull.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var intHolder = new Number<int?>(null); // T is int?, which can be null | |
var stringHolder = new Number<string>("Hello"); // T is string | |
var objectHolder = new Number<object>(new object()); // T is object | |
var nullableHolder = new Number<int?>(5); // T is int?, with a value | |
Console.WriteLine(intHolder.Value); // Output: null | |
Console.WriteLine(stringHolder.Value); // Output: Hello | |
Console.WriteLine(objectHolder.Value); // Output: System.Object | |
Console.WriteLine(nullableHolder.Value); // Output: 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment