I am starting to learn nullable types and ran into following behavior. While trying nullable int, i see comparison operator gives me unexpected result. For example, In my code...
PHP 7 introduces return type declarations. Which means I can now indicate the return value is a certain class, interface, array, callable or one of the newly hintable scalar...
If I have a nullable type Xyz?, I want to reference it or convert it to a non-nullable type Xyz. What is the idiomatic way of doing so in...
I have an enum string name; public enum Color { Red, Green, Yellow } How to set it to NULL on load. name = ""; Color color = null;...
Why does this not compile? int? number = true ? 5 : null; Type of conditional expression cannot be determined because there is no implicit conversion between ‘int’ and...
How do I check if a given object is nullable in other words how to implement the following method… bool IsNullableValueType(object o) { ... } I am looking for...
This question already has answers here: How to check if an object is nullable? (14 answers) Closed 9 years ago. In order to check if a Type ( propertyType...
There is paradox in the exception description: Nullable object must have a value (?!) This is the problem: I have a DateTimeExtended class, that has { DateTime? MyDataTime; int?...
This question already has answers here: Conditional operator assignment with Nullable<value> types? (6 answers) Why doesn’t this C# code compile? (4 answers) Closed 9 years ago. I just came...
How can I convert the nullable DateTime dt2 to a formatted string? DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString("yyyy-MM-dd hh:mm:ss")); //works DateTime? dt2 = DateTime.Now; Console.WriteLine(dt2.ToString("yyyy-MM-dd hh:mm:ss")); //gives following error: no...