Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class NullValues
- {
- static void Main()
- {
- int? integer = null;
- Console.WriteLine(integer.GetValueOrDefault() + 5);// (GetValueOrDefault() + 5) = 5
- Console.WriteLine(integer + 5);// null + 5 = null !
- float? floatInPoint = null;
- Console.WriteLine(floatInPoint.GetValueOrDefault()); // GetValueOrDefault() without literal
- integer = 5;
- floatInPoint = 10;
- Console.WriteLine(" Integer {0}, Float {1}",integer.GetValueOrDefault(),floatInPoint.GetValueOrDefault());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement