Re: [問題] C#與VB的整合
最近也在研究C#,沒想到這.NET強調的功能竟然找了好幾本書都沒有,
最後在Professional C#的電子書上找到類似的@@ 寫了個C#調用VB的
DLL的小程式,你參考一下。
File => New => Project => Visual Basic => Class Library
方案總管 => ClassLibrary1 => 右鍵 => Properties =>
Root Namespace => 改成CrossLangTest
Class1.vb
===========================================================
Public Class Class1
Public d() As Integer = {0, 1, 2, 3, 4, 5}
End Class
===========================================================
上面的會被編成ClassLibrary1.dll。
File => New => Project => Visual C# => Console Application
方案總管 => ConsoleApplication1 => 右鍵 => Add Reference
=> Browse => 加入剛才的ClassLibrary1.dll
Program.cs
===========================================================
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
CrossLangTest.Class1 oVB = new CrossLangTest.Class1();
foreach (int i in oVB.d)
{
Console.WriteLine("{0}", i.ToString());
}
}
}
}
===========================================================
output:
===========================================================
0
1
2
3
4
5
===========================================================
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.169.105.215
推
06/16 23:31, , 1F
06/16 23:31, 1F
→
06/17 02:28, , 2F
06/17 02:28, 2F
→
06/17 02:29, , 3F
06/17 02:29, 3F
→
06/17 02:31, , 4F
06/17 02:31, 4F
推
06/17 06:21, , 5F
06/17 06:21, 5F
討論串 (同標題文章)