调用DLL中的方法(转)

Posted on 2006-06-12 17:49  joinsky  阅读(408)  评论(0)    收藏  举报

我写个了小sample

1.cs

using System;

public class MyClass
{
   public static string GetStr()
   {
      return "this is a sample.. haha i am Taye";
   }
}

在cmd中
csc /t:library 1.cs

生成了1.dll


2.cs
using System;

public class MyClass2
{
   public static void Main()
   {
      Console.WriteLine(MyClass.GetStr());
   }
}

在cmd中
csc /t:exe 2.cs /r:1.dll
生成了2.exe

2.cs中使用了1.dll中的MyClss.GetStr()的一个静态方法。所以在编译时要先引用
/r:1.dll

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3