Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 13. Create a program that assigns null values to an integer and to double variables.
- // Try to print them on the console, try to add some values or the null literal to them and see the result.
- using System;
- using System.Text;
- class NullVariable
- {
- static void Main()
- {
- int? a = null;
- double? b = null; // It means that the value type in question is a nullable type
- Console.WriteLine("Printing the nullable variables: a: {0} b: {1}", a, b);
- a += null;
- b += 3.1415926; // !Important - Adding value to null variable results null!
- Console.WriteLine("Printing the nullable variables: a: {0} b: {1}", a, b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment