. NET Framework (part 2) (1)

Source: Internet
Author: User
. NET Framework (part 2) (1)

[Author: Unknown addition time: 8:11:13]

! [<H3> <B> 1. Process strings </B> <P class = "content"> the. NET Framework class (or system class) provides a large number of core functions that can be used to construct. NET applications. These functions are applicable to any language environment. The first part of this article introduces basic concepts such as assembly and namespace, as well as the system. Math and system. Random classes. This is the second part of this article. Next we will discuss several other useful classes: system. String, system. array, system. datetime.
<P class = "content"> it is worth noting that, as mentioned earlier in this article, when we use VB. net as a programming language, we often face the option of using VB. net Language built-in functions, or use the equivalent system class functions. We are faced with this option when processing array, date/time, and string data. If you were a VB
6.0 programmers, your first choice may be a tested and effective old method. However, if possible, you 'd better get rid of old habits and adopt the new. NET system class. Why? Because the use of the system class makes it easier for your code to be transplanted to other. NET languages and future VB. NET versions.
<P class = "content"> the system. string class provides rich string processing capabilities. Using the system. string class, we can: determine the length of the string, find the substring, change the case sensitivity of the string, compare two strings, split the string, and so on.
<P class = "content"> determine whether the string length uses the Length attribute. For example, in the following code, the value of intlength is 4:
<P class = "content"> <Table bgcolor = "# e9e9e9" cellspacing = 0 cellpadding = 5 width = 80% border = 1 bordercolorlight = "black" bordercolordark = "# ffffff"> <tr> <TD> <PRE> <P class = "content">
Dim strcolor as string = "blue"
Dim intlength as integer
Intlength = strcolor. Length
</PRE> </TD> </tr> </table>

<P class = "content"> we use the indexof method to find the first matched substring from the string. If a substring can be found, the indexof method returns the starting position of the substring (the starting position of the first character is 0). If not, indexof returns-1. Indexof is case sensitive. Indexof is a overload method. The parameters that can be passed in include: Char-type characters, string-type strings, and char-type character arrays. The following indexof. ASPX page demonstrates the use of three different parameter types indexof methods:
<P class = "content"> <Table bgcolor = "# e9e9e9" cellspacing = 0 cellpadding = 5 width = 80% border = 1 bordercolorlight = "black" bordercolordark = "# ffffff"> <tr> <TD> <PRE> <P class = "content">
& Lt; % @ page Language = "VB" Explicit = "true" % & gt;
& Lt; Head & gt;
& Lt; Title & gt; system. String instance & lt;/Title & gt;
& Lt; script language = "VB" runat = "server" & gt;
Sub page_load (SRC as object, e as eventargs)
Dim chrg as char = "G"
Dim strword as string = ""
Dim chrvowels as char () = {"A", "E", "I", "O", "U "}
Dim strphrase as string = _
"One small step for man, one giant leap for mankind ."
Dim I as integer

Lbloutput. Text & = "& lt; br/& gt; strphrase =" & strphrase
Lbloutput. Text & = "& lt; br/& gt; position of chrg = "_
& Strphrase. indexof (chrg)
Lbloutput. Text & = "& lt; br/& gt; position of strword = "_

Next page 8

Related content:

-. NET Framework win (Part 1)
-VB. NET Chinese tutorial (13) Whole-part relationship
-VB. NET Chinese tutorial (12) shared Member (shared Member)
-VB. NET Chinese tutorial (11) prototype Style
-VB. NET Chinese tutorial (9) overriding Program

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.