Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Last active December 25, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/6926687 to your computer and use it in GitHub Desktop.
Save Fhernd/6926687 to your computer and use it in GitHub Desktop.
Demostración de la accesbilidad de get y set en C#.
using System;
namespace PruebaAccesibilidad
{
public class Empleado
{
private string nombre;
public Empleado(string nombre)
{
this.nombre = nombre;
}
public string Nombre
{
get
{
return nombre;
}
private set
{
nombre = value;
}
}
}
public class PruebaEmpleado
{
public static void Main ()
{
Empleado empleado = new Empleado ("Edgar");
empleado.Nombre = "Melissa"; // se generará error en tiempo de compilación
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment