C #'s validity judgment,

Source: Internet
Author: User

C #'s validity judgment,

Reasonable object validity judgment during development is an important guarantee for program robustness and is also conducive to improving program execution efficiency. I have summarized several examples to determine whether the object is empty. The following is an example:

1. A collection object can contain null objects. When traversing a collection object, you must judge whether the objects in the set are empty. The example is as follows:

2. If the conversion fails when the object is converted in the as mode, null is returned. The example is as follows:

The above two examples are examples of validity judgment to be added, and the following example can be omitted.

3. You do not have to judge the number of datatables in the DataSet when you take values from DataSet Based on the DataTable name.

4. the return value of the Select function of DataTable is not empty. It can be provincial dr! = Null judgment

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.