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
|