Exemplo n.º 1
0
 public string this[int i]
 {
     get
     {
         if (i == 1)
         {
             return((Sexo == 1) ? ("Hombre") : ("Mujer"));
         }
         else
         if (i == 2)
         {
             return(DNI.ToString());
         }
         else
         if (i == 3)
         {
             return(FechaNacimiento.ToShortTimeString());
         }
         else
         if (i == 4)
         {
             return(Edad.ToString());
         }
         return("Indice invalido");
     }
     set
     {
         if (i == 1)
         {
             Sexo = ((Sexo == 1) ? (1) : (2));
         }
         else
         if (i == 2)
         {
             DNI = (Convert.ToInt32(value));
         }
         else
         if (i == 3)
         {
             FechaNacimiento = Convert.ToDateTime(value);
         }
         // no se puede asignar edad. se calcula.
     }
 }