Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 7, 2014 03:33
Show Gist options
  • Save Fhernd/5180c292ed7fb9f5a940 to your computer and use it in GitHub Desktop.
Save Fhernd/5180c292ed7fb9f5a940 to your computer and use it in GitHub Desktop.
Atributo personalizado en C#.
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