C# 4 optional parameter

2019-08-10 07:12发布

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

2条回答
Viruses.
2楼-- · 2019-08-10 07:58
beautiful°
3楼-- · 2019-08-10 08:16

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.

查看更多
登录 后发表回答