1
First, write class files, such as
Hello.cs
Using system;
Namespace Myclass.SAYHELLO
{
Public Class Tsayhello
{
String name;
Public tsayhello ()
{
THIS.NAME = "world";
}
Public String Say ()
{
Return ("Hello," this.name ");
}
}
}
2, compile custom class for DLL file
Csc.exe / target: library /r:system.dll Hello.cs
3, COPY generated hello.dll to the bin directory of the website root directory, if it is a virtual directory, copy to the BIN directory of the virtual directory
4, reference to custom class in the program
Using system;
Using system.Web.ui.webcontrols;
Using myclass.SAYHELLO;
/ / Reference Customized Namespace
Namespace myclasses
{
Public Class Ourgame: System.Web.ui.page
{
// Declare that the controls that will appear in Web Form
Public label lblsayhello;
Private Void Page_Load (Object Sender, System.EventArgs E)
{
Tsayhello myhello = new tsayhello ();
// Newly create a custom class object
LBLSAYHELLO.TEXT = myhello.say ();
}
}
}