23.2. Creating an Assembly
In its simplest form, an assembly is a single file with an .exe, .dll, or .module file extension. This file contains a single module and a manifest.
Let's create an assembly of type exe. You will need two source files: HelloWorld.cs and HelloWorldDriver.cs. The contents of the source files are shown in Listings 23.1 and 23.2.
Listing 23.1. HelloWorld.cs (C#)
public class HelloWorld { public override string ToString() { return "Hello World"; } } |
Listing 23.2. HelloWorldDriver.cs (C#)
using System; public class HelloWorldDriver { public static void Main(string[] args) { HelloWorld hw = new HelloWorld(); Console.WriteLine(hw.ToString()); } } |
Next, we use the following command to create an EXE assembly:
csc /target:exe ...
Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.