Advertisement
Fhernd

ConversionBooleanos.cs

May 19th, 2016
2,678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. class ConversionBooleanos
  2. {
  3.     static void Main()
  4.     {
  5.         // declaración de variable entera de 32 bits
  6.         int x = 123;
  7.        
  8.         // if (x) // Error: "Cannot implicitly convert type 'int' to 'bool'"
  9.         {
  10.             Console.WriteLine( "El valor de la variable 'x' es distinto de cero.");
  11.         }
  12.        
  13.         if (x != 0)
  14.         {
  15.             Console.WriteLine( "El valor de la variable 'x' es distinto de cero.");
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement