Is the new feature of C# 4.0 - “Optional Parameters” CLS-Compliant?

后端 未结 3 863
生来不讨喜
生来不讨喜 2021-02-05 02:51

This new feature is really convenient.

Lately I read the document of the \"Microsoft All-In-One Code Framework\", and it mentions that \"Optional Parameters\" is not CLS

3条回答
  •  眼角桃花
    2021-02-05 03:31

    Have a look at the CLS specs.
    From page 41:

    The vararg constraint can be included to indicate that all arguments past this point are optional. When it appears, the calling convention shall be one that supports variable argument lists.

    But the box right below says:

    CLS Rule 15: The vararg constraint is not part of the CLS, and the only calling convention supported by the CLS is the standard managed calling convention

提交回复
热议问题