C # encapsulates its own written DLL, and references its own dll__c#

Source: Internet
Author: User

1. How to encapsulate your own DLL;

A. Open Visual Studio-file-New-project-class library-name Mytestdll;

B. Right key Class1.cs-modified to TestDll.cs;

C. write a function in it that you want to manipulate, such as:

public int Fnadd (int iAdd1, int iAdd2)
{
Return (IADD1 + iAdd2);
}

D. Save-build solution;

E. This is your debug folder there will be a MyTestDll.dll file, you can put it in the project you want to quote;


2. Use your own encapsulated DLL file;

A. Open Visual Studio-file-new-project-Windows Forms application-name Usemydll;

B. Yourself on the form, add three TextBox controls, and a button control;

C. Place the MyTestDll.dll file under the Debug folder;

D. References-Add references-browse-add MyTestDll.dll;

E. Double-click the Button1 event:

private void Button1_Click (object sender, EventArgs e)
{
Mytestdll.testdll M_testdll = new Mytestdll.testdll ();

int a = convert.toint16 (TextBox1.Text);
int b = convert.toint16 (TextBox2.Text);

TextBox3.Text = convert.tostring (M_testdll.fnadd (a,b));
}

F. Run the program to start the experiment;


Tip: 1. The emphasis is on this sentence: Mytestdll.testdll m_testdll = new Mytestdll.testdll ();

2.[dllimput ("kernel32")] is generally used to add a DLL library with the system itself;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.