用C#和VB编写程序 [英] Write a program with both C# and VB

查看:105
本文介绍了用C#和VB编写程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想用C#编写一个桌面应用程序.但是,该程序会将短信发送到移动设备.短信网关提供商仅针对VB提供api.我可以用C#编码大多数项目,并在VB中编码sms部分吗?

Hi guys,

I want to write a desktop application with C#. But, this program will send sms to mobile devices. Sms gateway provider has api only for VB. Can I code most of the project with C# and code sms part in VB?

推荐答案

任何.Net程序集都可以用任何.Net语言引用

因此,可以的,您可以在C#项目中添加对VB.Net DLL的引用
Any .Net assembly can be referenced in any .Net language

So yes, you can add a reference to a VB.Net DLL in your C# project


.net语言,所有语言均会编译为IL,因此您使用的语言没有区别. br/>
话虽这么说,如果您对c#熟悉但您的库在VB中,请从该库中创建一个DLL,并在c#项目中引用该DLL,您将不知道它们之间的区别.
.net languages all compile down to IL so it makes no difference in what language you work in.

That being said if you are comfortable in c# but your library is in VB, create a DLL from that library and reference that DLL in your c# projects and you won''t know the difference.


使用其API的示例"代码很可能是用VB编写的,但是.Net不在乎您使用哪种语言.

这意味着您可以引用它们的程序集并使用任何.NET兼容语言(F#,C#等).您无需编码任何VB.

像往常一样创建解决方案/项目(我假设使用C#),然后引用dll.然后,您可以将其API与C#标记一起使用.

如果您坚持使用他们提供的示例,则可以使用在线
将其转换为
转换器 [
It is likely that the "example" code using their API is written in VB, however .Net does not care what language you use.

This means that you can reference their assemblie and use any .Net compliant language(F#, C# etc.) You do not ever need to code any VB.

Create a solution/project as you would normally (C# I assume) and then reference the dlls. You can then use their API with C# notation.

If you are stuck on their provided examples you can convert them using an online
converter[^].


这篇关于用C#和VB编写程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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