什么是.NET中的“CLSCompliant”属性? [英] What is the 'CLSCompliant' attribute in .NET?

查看:263
本文介绍了什么是.NET中的“CLSCompliant”属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是<一个href="http://msdn.microsoft.com/en-us/library/system.clscompliantattribute.aspx"><$c$c>CLSCompliant属性?

推荐答案

当你想确保它可以用于任何其他.NET语言您标记类与CLSCompliant属性。 这些是基本的规则:

You mark classes with the CLSCompliant attribute when you want to make sure it can be used by any other .NET language. These are the basic rules:

  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.

这篇关于什么是.NET中的“CLSCompliant”属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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