Asp. NET Developer's programming habits

Source: Internet
Author: User
Tags net string tostring

Making our programs more approachable and more vivid is a great benefit to our programming. To our program learning can also play a multiplier effect. The unwritten standards that are adhered to in the programming process are beneficial to our communication with others and to our own learning. After all, sometimes we write the program is not only for themselves to see, nor is it a momentary rise, regardless of the future. Good coding makes the source code readable and meaningful, consistent with other language conventions, and as intuitive as possible.

1. Handling of errors (other than)

The most basic requirement of program robustness is the process and capture of program error, in asp.net, the error processing has the same mechanism as other programming languages, you can use try ... Catch... Finally and so on, this is compared with the ASP has a greater progress. Moreover, using these error-handling methods can greatly improve the readability of the program and the speed of the program debugging, in the combination of these advantages, we should pay more attention to this point.

2. Handling of strings

In web design, the processing of strings is almost the most common. With ASP.net, strings are processed faster than ASPs, and in ASP.net, a string-handling class Stringbulider is used to perform some common string operations, and the most important, using StringBuilder can greatly increase string processing speed.

In ASP.net, the most common use of "&" is to connect two strings:

Dim myoutputstring as String = "My Name is"
Dim myinputstring as String = "Alex"
myoutputstring = myoutputstring & myinputstring
Response.Write (myoutputstring)
Now, let's look at the use of StringBuilder, when using StringBuilder, we can do some basic operations on strings, such as Append, Replace, Insert, remove, and so on, now we look at specific examples.

(1) The use of append in StringBuilder

Append, like the Append in other languages, is the addition of other characters at the end of the string.

-->dim sb as StringBuilder = New StringBuilder ()
Sb.append ("
")
Sb. Append (dt. Rows (i). Item (k, datarowversion.current). toString ())
Sb. Append ("
")
Dim stroutput as String = sb. ToString ()
Lblcompany.text = Stroutput



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.