C # Creating DLL files for program call methods

Source: Internet
Author: User

C # Creating DLL files for program call methods

To create a dynamic DLL file method using C #:

1. In the VS2017 environment, new-project-Select the class library type;

2. Create a new. cs file (such as Test.cs) and write the following code:

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceTestdll8 {9      Public classTestTen     { One         Private intA; A         Private intb; -  -          PublicTest (intAintb) the         { -              This. A =A; -              This. B =b; -         } +  -          Public intAdd () +         { A             returnA +b; at         } -  -          Public intAddintXinty) -         { -             returnX +y; -         } in  -      } to}

3. Click on the project-right-rebuild, open the folder-find the Debug folder, there is TestDll.dll file

4. Calling the TestDll.dll file method in the program

A. Add TestDll.dll to the reference and invoke the instance as:

1 using Testdll; 2  3 // instantiating an object 4 New Test (35); 5   // Call method 7MessageBox.Show (Test.add (). ToString ()); 8 MessageBox.Show (Test.add (5,5). ToString ());

C # Creating DLL files for program call methods

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.