How do I get at the attribute of the parameter in the following code?
public void SomeMethod([SomeAttribute] string s)
{
var someAttribute = ?
}
And I realize the attribute isn’t generally for use inside the method it’s on… just keeping the example simple though.
First you need a
MethodInfo:Then you can check for existence:
or get an instance (more expensive):