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