This article contains multiple modules in a program.
□Create 3 modules
→ Delete some files in the as folder of drive F, with only three files left
→ Open the myfirstmodule. CS file in notepad, modify the file as follows, and save
using System;
public class MyFirstModule
{
public static void Hello()
{
Console. writeline ("Greetings from Module 1 ~ ");
}
}
→ Open the mysecondmodule. CS file in notepad, modify the file as follows, and save
using System;
public class MySecondModule
{
public static void Hello()
{
Console. writeline ("Greetings from module 2 ~ ");
}
}
→ Compile myfirstmodule. CS class into Module
→ Compile mysecondmodule. CS class into Module
→ Create the mythirdmodule. CS file in the as folder of drive F, open it in notepad, write the following code, and save
using System;
public class MyThirdModule
{
public static void Hello()
{
Console. writeline ("Greetings from Module 3 ~ ");
}
}
→ Compile mythirdmodule. CS class into Module
□Create two assemblies and reference them for running
Now we need to create two sets, one containing myfirstmodule and mysecondmodule. Another Assembly contains mysecondmodule and mythirdmodule.
→ Create Assembly AssemblyA. dll including myfirstmodule and mysecondmodule.
→ Create Assembly Assemblyb. dll including mysecondmodule and mythirdmodule.
→ Compile the mainclass. CS file and reference the AssemblyA. dll assembly.
The above doscommand is equivalent to: CSC/R: AssemblyA. dll/out: mainclass.exe mainclass. CS
→Run mainclass.exe
→ Modify the mainclass. CS File
using System;
using System;
class MainClass
{
static void Main()
{
MySecondModule.Hello();
MyThirdModule.Hello();
}
}
→ Compile mainclass. CS and apply Assemblyb. dll assembly
→Run mainclassanother.exe
Summary: An assembly can contain multiple modules. If you place less commonly used code in a separate module, you can reduce the assembly loading time. If you download an Assembly over the network, you can also save bandwidth.
"C # Assembly series" includes:
C # Assembly series 01, use NotePad to write C # And il code, use the DOS command to compile the assembly, and run the C # Assembly series 02 program, use NotePad to view the Il code C # Assembly series 03 of the executable assembly, reference multiple Module C # Assembly series 04, understand the keyword internal C # Assembly generation 05 when the Assembly contains multiple modules, so that the Assembly contains multiple modules
References:
Http://www.computersciencevideos.org/created by Jamie King
C # Assembly generation 05, which contains multiple modules