标签:csc.exe program.cs 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
《CLR Via C#》使用CSC.exe将module组合成assembly
标签:csc.exe program.cs module assembly
原文地址:http://lsieun.blog.51cto.com/9210464/1753506