Advertisement
stefanpu

Why use double alias instead Double

May 22nd, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace UseDoubleAlias
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             object value = 23.5;
  13.  
  14.             // "is" operator checks if given value can be converted to
  15.             // given type.
  16.             // Converting from object to other type - unboxing.
  17.             // Note: Unboxing is one of the supported operations of
  18.             // "is" operator.
  19.             // See here for more on "is": http://msdn.microsoft.com/en-us/library/scekt9xw%28v=vs.71%29.aspx
  20.             if (value is Double)
  21.             {
  22.                 Console.WriteLine(value + " is Double.");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine(value + " is not Double.");
  27.             }
  28.  
  29.             if (value is System.Double)
  30.             {
  31.                 Console.WriteLine(value + " is System.Double.");
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine(value + " is not System.Double.");
  36.             }
  37.         }
  38.     }
  39.  
  40.     class Double
  41.     {
  42.         // Empty class(type) having the same name as System.Double.
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement