开发者

C#, J# and VB.NET is it possible to write a class in each and make its variables interact in one application?

I was asked this question in an interview w开发者_开发问答ould appreciate your answers.

Regards; Mohammad Mohsin


It's unclear exactly what the original interviewer meant - but if he was asking whether it's possible to combine code in .NET written in C#, J#, and VB.NET - the answer is yes - as long as each class is in a separate assembly. You cannot compile code from multiple languages into a single assembly.

As long as the code written in each is CLS compliant - you should be able to refer to the types and properties declared regardless of language. Language neutrality is one of the core design principles of .NET.

To answer your question from the comments... When you compile code i any .NET language, it is compiled into a common, intermediate representation which preserves metadata and type information. The .NET runtime is therefore able to load and interoperate code that may have been written in different .NET languages. This flexibility is made possible by several features of .NET, including the common type system, the CLR, and MSIL.


Yes, those languages all compile to a common intermediate language and all run in the managed framework.

If you wrote a class in each language (you would have a class library project for each), you could use those classes together in any project using a language targeting the .Net runtime.


It depends what you mean. Any public members on a class can be accessed, it would not matter what language the class was written in. They would need to be compiled into separate assemblies though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜