Skip to content

Instantly share code, notes, and snippets.

@aloon
Created March 28, 2013 13:55
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 aloon/5263296 to your computer and use it in GitHub Desktop.
Save aloon/5263296 to your computer and use it in GitHub Desktop.
Get the additional info inserted in property through attributtes
using System;
using System.Reflection;
class moreInfoAttribute : Attribute
{
public string valor { get; set; }
}
public class MyClass
{
[moreInfoAttribute(valor = "vale masInfo")]
public bool MyProp { get; set; }
}
class GetInfoAttribute
{
static void Main(string[] args)
{
string e = (typeof(MyClass).GetProperty("MyProp").GetCustomAttribute(typeof(moreInfoAttribute)) as moreInfoAttribute).valor;
Console.WriteLine(e);
}
}
@aloon
Copy link
Author

aloon commented Mar 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment