Fresh from Twitter, here are some ways to use attributes in C# that you might not know …

Did you know you can put attributes on method parameters

public string MyMethod([MyCustomAttribute] int id)
{
    // ...
}

Did you know you can specify an attribute on the return of a method …

[return: CrazyAttributeOnAReturnMethod(WithAParameterOfItsOwn = true)]
public string MyMethod(int id)
{
    // ...
}

For the record: I knew the first, but not the second …

Comments

blog comments powered by Disqus
Next Post
The unspoken truth about managing geeks  15 Feb 2011
Prior Post
Importing Excel data with SSIS  04 Feb 2011
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
February 2011
2011