Introduction to empty and nothing

Source: Internet
Author: User

Each programming language contains arrays. There are more or less differences between them, but there is no difference in general. The arrays I am talking about are used in VB. NET.


We are still working on the data center charging system these days. As code is getting more and more, some problems have also occurred in the code we wrote. Yesterday we met an array-related problem, my understanding of arrays is superficial. I think arrays only allow simple access to some data or objects. In fact, there are many array functions, such as sorting and quick retrieval, using Arrays can bring great benefits to programmers.


Here is an example to illustrate the usage of nothing.

Declare an array of storage objects


When determining whether the array Param is null, use the following statement and add parameters to the parameter array.

Dim param (0) as sqlparameter

Param (0) = nothing

If Param isnot nothing then

Sqlcmd. Parameters. addrange (PARAM)

End if


In this case, the addrange parameter cannot be empty. However, I have determined whether Param is not empty or an error occurs.


The reason should be that addrange () increases the value of each element in the array, and he needs to ensure that each element of the array is not a nothing. Param indicates the object of the array. If an element exists in the array, it indicates that the array is not a nothing. In this way, the above Code is correct.


Nothing is a reference to an empty object. If an object variable is set to null, the reference of this variable is released and the object is released.


Example: dim CNN as connection

CNN = nothing

Released the connection object CNN (variable.

Is the CNN object released here? We also need to determine

If CNN is nothing ............

Empty indicates a variable that has not been initialized. The data type of the variable is not required. It can be integer, String, Boolean, date, or object. Each data type has a default initialization value, depends on different programming languages.


The above is the general usage and definition in the book. What are the essential differences between them? What are their internal relationships? When can I mix them? Many problems still need to be understood in programming. It is not comprehensive because it only depends on 1.1 points.


I suddenly found that to write a program, I had to have a thorough understanding of the language so that I could use the language well !!

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.