Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // OrtizOL - xCSw - http://ortizol.blogspot.com
  2.  
  3. #define win7
  4. #define win8
  5. #define release
  6. #undef win2000
  7.  
  8. using System;
  9. using System.Diagnostics;
  10.  
  11. namespace Recetas.Capitulo01
  12. {
  13.     public class Plataforma
  14.     {
  15.         [Conditional("DEBUG")]
  16.         public static void MetodoCondicional()
  17.         {
  18.             Console.WriteLine ("Ingresó al método `MetodoCondicional`.");
  19.         }
  20.        
  21.         public static void Main (string[] args)
  22.         {
  23.             Console.WriteLine(Environment.NewLine);
  24.            
  25.             // declara objeto string para almacenar la plataforma identificada
  26.             // de acuerdo a la directiva evaluada
  27.             string plataformaIdentificada;
  28.            
  29.             #if win8
  30.                 plataformaIdentificada = "Microsoft Windows 8";
  31.             #elif winXP
  32.                 plataformaIdentificada = "Microsoft Windows XP";
  33.             #elif win2000
  34.                 plataformaIdentificada = "Microsoft Windows 2000";
  35.             #elif win7
  36.                 plataformaIdentificada = "Microsoft Windows 7";
  37.             #else
  38.                 plataformaIdentificada = "Desconocida";
  39.             #endif
  40.            
  41.             Console.WriteLine ("Plataforma identificada: {0}", plataformaIdentificada);
  42.            
  43.             // Ahora se invoca el método condicional. Esto ocurriré siempre
  44.             // y cuando el símbolo `DEBUG` haya sido definido:
  45.             MetodoCondicional ();
  46.            
  47.             Console.WriteLine(Environment.NewLine);
  48.         }
  49.     }
  50. }