C# 4 optional parameter

廉价感情. 提交于 2020-01-05 08:36:33

问题


Is C# 4 optional parameter implementation the same as VB.NET, the optional parameter is compiled on the call site(can cause versioning problems)?


回答1:


Yes.




回答2:


According to SamNg, C#'s default arguments are is compiled at the call site, similar to default parameters in C++.

Yes, it would cause versioning problems. However, optional parameters should be used where it makes sense. In many cases, this means passing null or default-constructed class to a method or constructor.



来源:https://stackoverflow.com/questions/664678/c-sharp-4-optional-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!