0% found this document useful (0 votes)
14 views1 page

Complete-Reference-Vb Net 12

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Complete-Reference-Vb Net 12

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Members of the String Class

Members of the String Class


Let's look at the members of the String class before we start using them in our example applications. Table
15−1 lists the important methods, minus most of the methods inherited from Object.

Clone

This member is inherited as it is in all the .NET types, but it is especially useful in the String class. It lets you
declare a new object and then clone another object to it bit for bit. You then end up with two identical copies
of the String. You can then work with the new object in place of the cloned one. The following code
demonstrates the cloning of a String object:

Dim sText, sTextDisplay As String


Dim sClone As Object
sText = "hello world"
sClone = sText.Clone()
sTextDisplay = sClone.ToString()
Console.WriteLine("Result: {0}", sTextDisplay)

Table 15−1: String Manipulation Methods and Properties (Several are Static)

What You Need to Do Method or Property to Use


Get the Char at a specific index in the String Char (p)
Get the length of the String Length (p)
Compare two Strings Compare (s), CompareOrdinal (s)
Compare a target String to a source String CompareTo
Join source String to target String Concat (s)
Copy source String object to target String Copy (s)
Clone the source String Clone
Copy characters into an array CopyTo
Test the beginning and ends of Strings EndsWith, StartsWith
Format numeric Strings Format (s)
Get the index location of characters in a String IndexOf, LastIndexOf, LastIndexOfAny
Insert sub−Strings into a String Insert
Obtain a reference to a String Intern (s), IsInterned (s)
Manipulate sub−Strings Join, Split (s)
Pad Strings with additional characters PadLeft, PadRight
Remove characters from a String Remove
Replace characters in a String Replace
Isolate a sub−String from a String SubString
Trim characters from the beginning and ends of Strings Trim, TrimEnd, TrimStart
Copy the characters in the String to a Unicode character array ToCharArray
Covert all characters in the String to lowercase ToLower
Return the value of the String object ToString
Convert all the characters in the String to uppercase ToUpper

496

You might also like