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
Queue Testing  08 Dec 2018
Creating Branching Nodes  01 Dec 2018
Two Dual Item Queues  24 Nov 2018
Simple Queues  17 Nov 2018
Enqueuing Values  10 Nov 2018
Dequeuing Values  03 Nov 2018
Designing the External API  27 Oct 2018
Introducing the Priority Queue  20 Oct 2018
A better approach to reflection  13 Oct 2018
Avoiding Magic Strings  06 Oct 2018
More csharp posts »
Archives
February 2011
2011