简体   繁体   English

C#接口可以继承哪些语言?

[英]C# Interface can be inherited in which languages?

We have designed an API which exposes a series of interfaces written in C#. 我们设计了一个API,该API公开了一系列用C#编写的接口。

  • Apart from C# what languages can inherit from the C# interface? 除了C#,哪些语言可以从C#接口继承?

The motivation behind this question is that we are writing the API documentation and would like to state which languages can utilise the interfaces we have written in C#. 这个问题背后的动机是我们正在编写API文档,并希望说明哪些语言可以利用我们用C#编写的接口。

For example can VB.NET or F# inherit an interface written in C#? 例如,VB.NET或F#可以继承用C#编写的接口吗?

EDIT ---- 编辑----
I should note that I have since discovered the CLSCompliant attribute which forces the compiler to check for Common Language Specification (CLS) compliance at compile time. 我应该注意,此后我发现了CLSCompliant属性,该属性强制编译器在编译时检查是否符合公共语言规范(CLS)。 This is a useful attribute for public API's to ensure compliance with other .NET languages. 这是公共API的有用属性,可确保与其他.NET语言兼容。

Link to article explaining the use of the CLSCompliant atribute 链接到解释CLSCompliant属性用法的文章

If you stick to CLS (Common Language Specification), you can inherit that interfaces in all CLS compliant languages. 如果您坚持使用CLS(通用语言规范),则可以使用所有CLS兼容语言继承该接口。 For example Visual Basic, F# are CLS compliant and can inherit C# classes and interfaces. 例如,Visual Basic,F#符合CLS,并且可以继承C#类和接口。

An example: You cannot have the same names which only differ by case - eg METHOD(), method(), Method(), mEtHoD()... these ones cannot be present together in one interface. 例如:您不能使用仅因大小写而不同的相同名称-例如METHOD(),method(),Method(),mEtHoD()...这些名称不能一起出现在一个接口中。

Some programming languages may support only older CLS specification. 某些编程语言可能仅支持较旧的CLS规范。 For example CLS 1.0 languages don't support generic types. 例如,CLS 1.0语言不支持泛型。

You can found more information on CLS requirements in MSDN. 您可以在MSDN中找到有关CLS要求的更多信息。

http://msdn.microsoft.com/en-us/library/12a7a7h3.aspx http://msdn.microsoft.com/en-us/library/12a7a7h3.aspx

http://msdn.microsoft.com/en-us/library/a2c7tshk.aspx http://msdn.microsoft.com/en-us/library/a2c7tshk.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM