小编给大家分享一下如何使用CSC.exe将module组合成assembly,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

代码如下:
using System;
namespace MyClassLib
{
public class FrequentlyUsedCalculator
{
public int Add(int a, int b)
{
return a + b;
}
public int Sub(int a, int b)
{
return a - b;
}
}
}csc.exe /t:module FrequentlyUsedCalculator.cs
代码如下:
using System;
namespace MyClassLib
{
public class RarelyUsedCalculator
{
public int Multiple(int a,int b)
{
return a * b;
}
public int Divide(int a, int b)
{
return a / b;
}
}
}csc.exe /t:module RarelyUsedCalculator.cs

al.exe /out:MyClassLib.dll /t:library FrequentlyUsedCalculator.netmodule RarelyUsedCalculator.netmodule

using System;
using MyClassLib;
namespace MyConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入第一个整数:");
int number1 = Convert.ToInt32(Console.ReadLine());
Console.Write("请输入第二个整数:");
int number2 = Convert.ToInt32(Console.ReadLine());
FrequentlyUsedCalculator cal1 = new FrequentlyUsedCalculator();
Console.WriteLine("{0} + {1} = {2}", number1, number2, cal1.Add(number1, number2));
Console.WriteLine("{0} - {1} = {2}", number1, number2, cal1.Sub(number1, number2));
RarelyUsedCalculator cal2 = new RarelyUsedCalculator();
Console.WriteLine("{0} * {1} = {2}", number1, number2, cal2.Multiple(number1, number2));
Console.WriteLine("{0} / {1} = {2}", number1, number2, cal2.Divide(number1, number2));
Console.ReadKey();
}
}
}csc.exe /out:Program.exe /t:exe /r:MyClassLib.dll Program.cs


以上是“如何使用CSC.exe将module组合成assembly”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联网站制作公司行业资讯频道!
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。