A many/multi-core blog

This blog is dedicated to the new many-core/multi-core programming techniques, especially the ones available in Visual Studio 2010.

The new optional parameter in C#

When I first read about the new optional and named parameters features in C# 4.0, I was very excited, I said, finally, something that I appreciated in C++ is now available in C# too.

But couple of days ago I was reading somewhere (I don’t remember where, but when I will, I will update this post) about those, and a comment drew my attention. Optional parameters are treated  like constants. So I had to test that. What does this means? It means that if you have a library with a method that uses optional parameters, and you call that method from another assembly without specifying values for those optional parameters, you will actually bind your method call to their default values as if they were constants. So if you will update the value of the default parameter later on, then you have to recompile the calling assembly too. I will upload a video on www.cludcasts.net soon to prove this.