Created
June 7, 2014 03:33
-
-
Save Fhernd/5180c292ed7fb9f5a940 to your computer and use it in GitHub Desktop.
Atributo personalizado en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Recetas.Cap03 | |
{ | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, | |
AllowMultiple = true, Inherited = false)] | |
public class AutorAttribute : Attribute | |
{ | |
private string organizacion; | |
private string nombre; | |
// Constructor público: | |
public AutorAttribute (string nombre) | |
{ | |
this.nombre = nombre; | |
organizacion = String.Empty; | |
} | |
// Accede y modifica el nombre de la organización: | |
public string Organizacion | |
{ | |
get | |
{ | |
return organizacion; | |
} | |
set | |
{ | |
organizacion = value; | |
} | |
} | |
// Propiedad de sólo lectura (campo opcional): | |
public string Nombre | |
{ | |
get | |
{ | |
return nombre; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment