.NET Framework中的语言互操作性(基本概念)是什么? [英] What is language interoperability (basic concept) in .NET Framework?
问题描述
我正在阅读Wikipedia中的 .NET Framework 文章,在第一段中介绍了该框架的一般概念,它说:
I'm reading .NET Framework article in Wikipedia, in the first paragraph describes the general concept of this framework, and it says:
它包括一个大型库,并提供跨几种编程语言的语言互操作性(每种语言都可以使用用其他语言编写的代码).
当它声明.NET提供语言互操作性时,共享的是什么:代码还是代码功能?
When it declared that .NET provides language interoperability, what is shared: the code or the code functionality?
例如,我有以下简单代码:
For example, I have the following simple code:
class Math
{
public double Pow( double a, double b)
{
return Math.Pow(a,b);
}
}
我可以访问C#代码或Math对象的实例化吗?
Do I have access to the C# code or the instantiation of the Math object?
推荐答案
编译C#程序时,它会编译为IL(中间语言).然后,该编译程序可以被任何其他.NET语言使用,例如,Visual Basic程序可以引用您的程序,创建Math类的实例并使用它.
When you compile your C# program, it is compiled into IL (Intermediate Language). That compiled program can then be used by any other .NET language, for example a Visual Basic program could reference yours, create an instance of your Math class and use it.
Visual Basic不在乎(或知道)您的Math类是用C#编写的,它看到的只是一个.NET类.这就是语言的互操作性.如果VB.NET只能使用VB.NET编写的类,而C#只能使用C#编写的类,则这些语言将无法互操作.
Visual Basic doesn't care (or know) that your Math class was written in C#, all it sees is a .NET class. That's language interoperability. If VB.NET could only use classes written in VB.NET, and C# could only use classes written C#, those languages wouldn't be interoperable.
这篇关于.NET Framework中的语言互操作性(基本概念)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!