2. Optimized string operation performance
Use the tostring method of the Value Type
When connecting strings, you often use the "+" sign to directly add numbers to strings. This method is simple and can get the correct results. However, because different data types are involved, the numbers must be converted to the reference type through the boxing operation before they can be added to the string. However, the packing operation has a great impact on the performance, because during such processing, a new object will be allocated in the managed heap, and the original value will be copied to the newly created object. The Value Type tostring method can be used to avoid packing, thus improving the applicationProgramPerformance.
Use stringbuilder class
The string class object cannot be changed. In essence, the re-assignment of the string object re-creates a String object and assigns the new value to the object, the tostring method does not significantly improve the performance. When processing strings, it is best to use the stringbuilder class. Its. Net namespace is system. Text. This class does not create a new object, but directly performs operations on strings through append, remove, insert, and other methods, and returns the operation results through the tostring method.
Its definition and operation statement are as follows:
Int num;
System. Text. stringbuilder STR = new system. Text. stringbuilder (); // create a string
Str. append (Num. tostring (); // Add the numeric value num
Response. Write (Str. tostring); // display the operation result. 3. Optimize the configuration files for Web server computers and specific applications to meet your specific needs.
By default, ASP. NET configuration is set to enable the widest range of features and adapt to the most common solutions. Therefore, application developers can optimize and modify some of the configurations based on the features used by the application to improve application performance. The following lists some options you should consider.