How to create and use classes and class libraries in a C # project

Source: Internet
Author: User

Create a Class library project
On the File menu, choose New Project.

In the New Project dialog box, in the Templates pane, click Class Library.

In the Name box, type Persons, and then click OK.

Tick "Add a new Solution" and select "put into solution." ”

A new Class library project opens, and the code Editor displays the class module Class1.cs.

In Solution Explorer, right-click Class1.cs and select Rename, and then change the name to Persons.cs.

Note that the name in the code editor is also changed to Persons.cs.

On the File menu, choose Save All.

In the Save Project dialog box, click Save.

Once a class library is created, a production class library is generated. DLL file, and then you need the project application on OK!!

In addition

The steps for developing a three-tier architecture and referencing your own class library DLLs to a Web project are as follows:
If you follow the PetShop4.0 standard, this is probably the case.
1. Create model to realize business entity.

2, create idal, implement interface.

3, create Sqlserverdal, implement the method in the interface. (If the dbutility layer is used, it is established before this step)

4. Add the configuration information in Web. config to the Sqlserverdal assembly.

5. Create a dalfactory that returns an instance of the specified class of the assembly.

6, create the BLL, call Dalfactory, get an instance of the specified class of the assembly, complete the data operation method.

7. Create the Web and call the data manipulation method in the BLL.

Two. Add references to projects on the project, the referenced project DLL will be automatically generated into the bin of the referenced project, and LZ several said the results are the same.
Share

How to create and use classes and class libraries in a C # project

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.