O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

F.4. Creating DLL assemblies using csc.exe

If you are using csc.exe, you will need to know how to reference classes coded in other assemblies using the /reference option.

Let's say you have two classes, called MyClass1 and MyClass2, in separate source files. [4] MyClass1 creates a new instance of MyClass2 in its Main method.

[4] Of course, you can put them into the same source file and no referring will be required. But I am trying to show how you can reference something coded in another source file (which will eventually be compiled into a separate assembly).

1: // MyClass1.cs
2: public class MyClass1{
3:   public static void Main(){
4:     MyClass2 mc2 = new MyClass2();
5:     System.Console.WriteLine(mc2.Add(3,4));
6:   }
7: }
 1: // MyClass2.cs – in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required