Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-9pm4c Total loading time: 0 Render date: 2024-04-27T22:26:30.455Z Has data issue: false hasContentIssue false

Chapter 7 - Strings, the String Class, and the StringBuilder Class

Published online by Cambridge University Press:  11 August 2009

Michael McMillan
Affiliation:
Pulaski Technical College, Arkansas
Get access

Summary

Strings are common to most computer programs. Certain types of programs, such as word processors and Web applications, make heavy use of strings, which forces the programmer of such applications to pay special attention to the efficiency of string processing. In this chapter we examine how VB.NET works with strings, how to use the String class, and how to work with the StringBuilder class. The StringBuilder class is used when a program must make many changes to a String object because strings and String objects are immutable, whereas StringBuilder objects are mutable. We'll explain all this later in the chapter.

WORKING WITH THE STRING CLASS

A string is a series of characters that can include letters, numbers, and other symbols. String literals are created in VB.NET by enclosing a series of characters within a set of double quotation marks. Here are some examples of string literals:

  1. “David Ruff”

  2. “the quick brown fox jumped over the lazy dog”

  3. “123-45-6789”

  4. “mmcmillan@pulaskitech.edu”

A string can consist of any character that is part of the Unicode character set. A string can also consist of no characters. This special string, called the empty string, is shown by placing two double quotation marks next to each other (“”). Keep in mind that this is not the string that represents a space. That string looks like this: “ ”.

Strings in VB.NET have a schizophrenic nature: They are both native types and objects of a class.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2005

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

Available formats
×