Argument type is not CLS-compliant, why?

后端 未结 3 1593
忘掉有多难
忘掉有多难 2020-12-15 16:20

I get the warning like this \"alt If you know what it is, please exp

3条回答
  •  伪装坚强ぢ
    2020-12-15 16:33

    This is an old question, but I thought a better explanation was due for future investigators (such as myself).

    First off, the links in the other answers provide great detail into the reason this warning is given.

    However, to summarize, code written for the Common Language Runtime (such as C#) is CLS-Compliant if it can interface with other languages designed for the CLR. This means that certain datatypes specific to the language that are not common to the entire runtime are not compliant. The quick and easy fix for this in regards to variables and methods is to give them the visibility modifier internal which specifies that the method, class, property, etc. is not visible outside of the assembly it is being built for. This should only be done on those items which you do not need or want to be used outside of the assembly; for those that you want visible, use datatypes that are CLS-compliant.

提交回复
热议问题