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
Short-circuiting validation  11 Aug 2018
Aggregation of validation  04 Aug 2018
Recovery of validation types  28 Jul 2018
Basic validation  21 Jul 2018
Why we need better validation  07 Jul 2018
A question of struct performance  30 Jun 2018
Equality has Symmetry  17 Mar 2018
Type Miscellany  05 Mar 2017
Testing Immutable Types  25 Feb 2017
Factory Methods  18 Feb 2017
More csharp posts »
Archives
February 2011
2011