How to add your own code to strongly typed DS?

Source: Internet
Author: User
The strongly typed DS is constructed by the designer. But how can I add my own code? After painstaking and excellent research, I finally found out !! 1. Create a New DS file and display its sub-files,
In VS2003, it is *. cs. In vs2005, It is the *. Designer. cs file, which is the code file defining DS. You can add your own code here. There is a problem! If you save this DS, your code will disappear !!! This is unacceptable! 2. If you use vs2005, please be happy !! On the Design page, right-click
A file is generated:

You can edit it here. Unfortunately, vs2003 does not support it. However, you must comply with the constraint of the partial keyword!

There is a problem with the above method. If you want to delete DS, the code you write will be deleted together. Logically, it can be said that (no skin is available, why ?), But what if I don't want to delete it? Extended: Because C #2.0 supports the partial keyword, it can still be implemented without the above method. If there is a strong DS type named "DataSet1", there is a table named "DataTable1" below, and then add a class, modify the code as follows: namespace ConsoleApplication3
{Public partial class DataSet1
{
Public string zp = string. Empty; public partial class DataTable1DataTable
{
Public string wx = string. Empty;
}
}
} Done !! The added code is no longer subject to DS! In this way, strong DS and their own code can work together!

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.