string str=null; and string str= ""; the difference (net picks)

Source: Internet
Author: User
First, a string in C # is a string, but its underlying implementation is still an array of characters. And string is a reference type, and its underlying implementation is necessarily a pointer, because the underlying implementation of string is the traditional string implementation in C, which points to a pointer to a character array.
At this point, the difference between string str=null and string str= "" can be clearly seen.
The substance of string str=null is char *ps = 0;
String Str= ""; The essence is char *ps= ""; or char *ps= "/0";
Other words
String Str=null, which indicates that STR is a pointer to 0. Does not allocate any memory space.
String Str= ""; Represents the array of characters in which Str points to the first element of 0 (the string ending flag). Allocates memory space, but the first memory space is 0.

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.