C# Tutorials - Herong's Tutorial Examples - v3.31, by Dr. Herong Yang
Generating and Using .NET Library Files
This section provides a tutorial example on how to compile C# source code files into library files and use them as references when compile other source code files.
If you have a program with multiple C# source code files, you can:
Let's use two source files, "Util.cs" and "SwapTest.cs" described in the previous section to try this:
1. Compile "Util.cs" into a library file, "Util.dll":
C:\herong>\Windows\Microsoft.NET\Framework\v4.0.30319\csc /target:library Util.cs C:\herong>dir Util.* 210 Util.cs 3,072 Util.dll
2. Compile "SwapTest.cs" with reference to the library file, "Util.dll":
C:\herong>\Windows\Microsoft.NET\Framework\v4.0.30319\csc UtilTest.cs /reference:Util.dll SwapTest.cs C:\herong>dir SwapTest.* 329 SwapTest.cs 3,072 SwapTest.exe
3. Run the executable file "SwapTest.exe", you will get the program output:
C:\herong>SwapTest.exe Herong Yang Yang Herong
Now we learned how to generate and use .NET library files.
Table of Contents