I want some Moore

Blog about stuff and things and stuff. Mostly about SQL server and .Net
posts - 226, comments - 2295, trackbacks - 33

My Links



Hi! My name is 
Mladen Prajdić  I'm from Slovenia and I'm currently working as a .Net (C#) and SQL Server developer.

I also speak at local user group meetings and conferences like SQLBits and NT Conference
Welcome to my blog.
SQL Server MVP

My Books

SQL Server MVP Deep Dives 2
The Red Gate Guide to SQL Server Team based Development Free e-book

My Blog Feed via Email
Follow MladenPrajdic on Twitter

Users Online: who's online

Article Categories


Post Categories

Cool software

Other Blogs

Other stuff

SQL stuff

C# 2.0: Arity - ever heard of it?


Arity is the number of arguments that a method takes.

For example

void MyMethod(int i1, int i2)


has an arity of 2, since it takes 2 arguments.

In C# the arity is marked with `


"So why is this important?", you might ask.

Well it isn't. Until you deal with reflection. :)

A while ago I had to create some code using CodeDOM and i was getting a few errors that the ` in code isn't correct

when i tried to compile the code.


Here's an example of how arity is shown using reflection:

List<string> list = new List<string>();

// output: System.Collections.Generic.List`1[System.String]

Dictionary<int, string> dict = new Dictionary<int, string>();

// output: System.Collections.Generic.Dictionary`2[System.Int32,System.String]


You can see that the ` is used to tell us how many arguments a generic type uses.

kick it on DotNetKicks.com

Print | posted on Friday, June 08, 2007 6:01 PM | Filed Under [ .Net ]



# re: C# 2.0: Arity - ever heard of it?

I think you are confusing something, you are talking about GENERIC parameters, not normal params
6/14/2007 12:30 PM | Ayende Rahien

# re: C# 2.0: Arity - ever heard of it?

Ayende is right... it<s seem to be only for GENERICS... but that<s cool to know that, i tried to use reflection often as i can in my projects.
6/14/2007 1:33 PM | Eric

# re: C# 2.0: Arity - ever heard of it?

emm... confusing? no not really.

Arity in .net is displayed only for generic params
and it shows how many of them the type needs.

maybe it's displayed for methods in some way too, but
i haven't seen it so far.

the void MyMethod(int i1, int i2) was only an example of what arity means.
6/14/2007 1:33 PM | Mladen
Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET