Asp.ent combined with two Datatable_ practical tips for the same structure

Source: Internet
Author: User
Wrote a function.
Copy Code code as follows:

<summary>
Merge two identical DataTable to return the merged results
</summary>
<param name= "DT1" ></param>
<param name= "DT2" ></param>
<returns></returns>
Public DataTable Combinethesamedatatable (DataTable Dt1, DataTable DT2)
{
if (DT1. Rows.Count = = 0 && dt2. Rows.Count = 0)
{
return new DataTable ();
}
if (DT1. Rows.Count = 0)
{
return DT2;
}
if (DT2. Rows.Count = 0)
{
return DT1;
}
DataSet ds = new DataSet ();
Ds. Tables.add (DT1. Copy ());
Ds. Merge (DT2. Copy ());
Return DS. Tables[0];
}

Because of the limited understanding of C #, so I do not understand why the dt1==null can not correctly judge the empty table, so the use of a number of lines of method. Also hope that high man can guide twos.

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.