0
点赞
收藏
分享

微信扫一扫

C# csc构建dll 和 csc构建时指定dll

鲤鱼打个滚 2023-07-04 阅读 25
c#cscdll

新建一个mydll.cs;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace myDLL
{
    public class MyMath
    {
        public int add(int x, int y)
        {
            return x + y;
        }

        public int sub(int x, int y)
        {
            return x - y;
        }
    }
}

用下图命令构建为dll;看下dll有了; 

新建一个testdll.cs;

using System;
using myDLL;

class Program
{

static void Main(string[] args)
{
    MyMath a = new MyMath();
    int c = a.add(99, 77);
    Console.WriteLine("99+77=" + c);

    Console.ReadKey();
}

}

目前都是在同一目录;构建testdll.cs;出错; 

 

看一下指定需要的dll是不是 /addmodule ,错了,

 

用 /r 指定需要的dll,然后构建;构建成功,运行如下;

 

 

举报

相关推荐

0 条评论