参数类型不符合CLS的,为什么呢? [英] Argument type is not CLS-compliant, why?

查看:1390
本文介绍了参数类型不符合CLS的,为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这样的
警告
如果你知道它是什么,请解释和放大器;帮我摆脱它。
南。

I get the warning like this If you know what it is, please explain & help me to get rid of it. Nam.

推荐答案

在你的AssemblyInfo.cs文件,你可能有这样一行:

In your AssemblyInfo.cs file, you've probably got a line that reads

[assembly:CLSCompliant(true)]

如果你这样做,那么下面的规则必须得到满足。 (拷贝面食从 http://www.devarticles.com/ C / A / C-夏普/制作 - 您 - 代码符合CLS /

If you do, then the following rules must be met. (Copy-Pasta from http://www.devarticles.com/c/a/C-Sharp/Making-Your-Code-CLS-Compliant/)


  1. 无符号类型不应该之类的公共接口的一部分。这意味着公共领域不应该有符号类型,如UINT或ulong,则公共方法不应返回无符号类型,传递给公众函数的参数不应该无符号类型。但是无符号类型可以是私有的部分成员。

  1. Unsigned types should not be part of the public interface of the class. What this means is public fields should not have unsigned types like uint or ulong, public methods should not return unsigned types, parameters passed to public function should not have unsigned types. However unsigned types can be part of private members.

不安全类型,如指针不应该与公众成员使用。然而,它们可以与私有成员使用。

Unsafe types like pointers should not be used with public members. However they can be used with private members.

类名和成员名称不应该区别仅仅根据他们的情况。例如,我们不能有一个名为的MyMethod和myMethod的两种方法。

Class names and member names should not differ only based on their case. For example we cannot have two methods named MyMethod and MYMETHOD.

只有属性和方法可能过载,运营商不应过多。

Only properties and methods may be overloaded, Operators should not be overloaded.

这篇关于参数类型不符合CLS的,为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆