C# Tutorials - Herong's Tutorial Examples - v3.32, by 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
Logical Expressions and Conditional Statements
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
►Compiling C# Source Code Files
Multiple Classes in a Single Source File
Compiling Multiple Source Code Files Together
►Generating and Using .NET Library Files
MSBuild - Microsoft Build Engine
System.Diagnostics.FileVersionInfo Class
WPF - Windows Presentation Foundation