Advertisement
AnitaN

02.PrimitiveDataTypesVariables/13.NullValuesArithmetic

Mar 11th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. //Problem 13.   Null Values Arithmetic
  2. //Create a program that assigns null values to an integer and to a double variable. Try to print these variables at the console. Try to add some number or the null literal to these variables and print the result.
  3.  
  4. using System;
  5.  
  6. class NullValuesArithmetic
  7. {
  8.     static void Main()
  9.     {
  10.         int? nullValueFirst = null;
  11.         double? nullValueSecond = null;
  12.         Console.WriteLine("First variable is {0} and Second variable is {1}", nullValueFirst, nullValueSecond);
  13.         Console.WriteLine(nullValueFirst + nullValueSecond);
  14.         Console.WriteLine(nullValueFirst + 10);
  15.         nullValueFirst = 2;
  16.         Console.WriteLine(nullValueFirst.GetValueOrDefault());
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement