Can you use optional parameters in code targeting .NET 3.5?

后端 未结 7 927
独厮守ぢ
独厮守ぢ 2020-11-30 10:46

I\'m looking to write a library that uses the new optional parameters feature of C# 4.0, but I want to target it to the 3.5 version of the framework. Is this possible?

7条回答
  •  佛祖请我去吃肉
    2020-11-30 11:40

    I don't have VS2010 installed here to check, but I believe this would be purely a language feature, and therefore should be usable regardless of the framework being targeted.

    Edit: Looking at this link (and a few others), it appears that optional parameters compile to method arguments with an [opt] attribute in the il. I don't know if this parameter existed in previous versions of the clr, but still my guess would be that it does.

提交回复
热议问题