Skip to content

Instantly share code, notes, and snippets.

@WiredUK
Created October 6, 2016 14:43
Show Gist options
  • Save WiredUK/9e511ba71df22e3190ca333dbdc788cb to your computer and use it in GitHub Desktop.
Save WiredUK/9e511ba71df22e3190ca333dbdc788cb to your computer and use it in GitHub Desktop.
[Blah(SomeValue = 4)]
public void DoStuff()
{
var method = MethodBase.GetCurrentMethod();
var attr = (BlahAttribute)method.GetCustomAttributes(typeof(BlahAttribute), true)[0];
var value = attr.SomeValue;
Console.WriteLine(value);
}
private class BlahAttribute : Attribute
{
public int SomeValue { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment