C # string processing, object reference and inheritance (Tenth day)

Source: Internet
Author: User

C # string processing, object reference and inheritance (Tenth day)
It's another week. Now it's time to sum up. Let's continue to summarize what we 've learned in cloud and college. Theory: The difference between StringBuilder and String: A new instance is generated during operations (such as assignment and concatenation), while StringBuilder does not. Therefore, it is best to use StringBuilder when splicing a large number of strings or frequently performing operations on a certain String. Do not use String. If you want to operate a growing String, try not to use the String class, instead use the StringBuilder class. The two classes work in different ways: the String class is a traditional way of modifying strings. It can indeed add a String to another String, but in.. Because the system first writes two strings to the memory, then deletes the original String object, creates a String object, and reads the data in the memory and assigns it. This process takes a lot of time. The StringBuilder class under the System. Text namespace is not like this. It provides the Append method, which can be used to modify strings in the existing object, which is simple and direct. Of course, the efficiency difference between the two is usually not noticed, but if you want to add a large number of operations to a string, the time consumed by the StringBuilder class and the String class are not an order of magnitude. The int, decimal, bool, and double byte enumeration types (value types) of the object are transmitted copies, and the object (reference type) is transmitted references. If the constructor is written, all fields in the structure must be assigned a value. If the constructor is written in the structure, the default constructor is also, unlike a class, a constructor with parameters is written in the class. A non-parameter constructor is killed directly. In the constructor of the class, you do not need to assign values to all fields.

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.