Asp. NET programming habits

Source: Internet
Author: User
Beginners programming friends often like to collect some very "wonderful" programming skills, however, the accumulation of skills often did not improve the quality of the program, but to guide some programmers blindly pursuit of strange and new, forget the basic programming habits of training, not conducive to teamwork, perhaps, this is China is not lack of intelligent programmers, But one reason for the lack of a smart development team. In the development of ASP.net, we can learn a lot of skills, but some basic programming habits we must develop, so that not only can fundamentally improve the quality of the program and development efficiency, but also conducive to the reading of the program and team development. If you write the program only you can read or only a few people can understand, even if the program skills gadget its technology, for the program upgrades and maintenance are fatal problems.
I. Processing 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.
For error handling, we can refer to this article (in English):
http://www.123aspx.com/redir.aspx?res=28336
Second, the processing 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 ("<table border= ' 1 ' width= ' 80% ' >")
For i = 0 to RowCount-1
Sb. Append ("<tr>")
For k = 0 to ColCount-1
Sb. Append ("<td>")

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.