Advertisement
Fhernd

Empleado.cs

Nov 14th, 2017
1,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PruebaAccesibilidad
  4. {
  5.     public class Empleado
  6.     {
  7.         private string nombre;
  8.        
  9.         public Empleado(string nombre)
  10.         {
  11.             this.nombre = nombre;
  12.         }
  13.        
  14.         public string Nombre
  15.         {
  16.             get
  17.             {
  18.                 return nombre;
  19.             }
  20.             private set
  21.             {
  22.                 nombre = value;
  23.             }
  24.         }
  25.     }
  26.    
  27.     public class PruebaEmpleado
  28.     {
  29.         public static void Main ()
  30.         {
  31.             Empleado empleado = new Empleado ("Edgar");
  32.                    
  33.             empleado.Nombre = "Melissa"; // se generará error en tiempo de compilación
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement