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 ...
Get From Java to C#: A Developer's Guide 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.