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
Explicit Interfaces and Delegate Properties  16 Feb 2019
Extension Methods  19 Jan 2019
Generating Hash Codes  12 Jan 2019
The Problem with Equality  05 Jan 2019
Queue Equality  29 Dec 2018
Smarter Queue Enumeration  22 Dec 2018
Queue Enumeration  15 Dec 2018
Queue Testing  08 Dec 2018
Creating Branching Nodes  01 Dec 2018
Two Dual Item Queues  24 Nov 2018
More csharp posts »
Archives
February 2011
2011