...

/

Working with Text: Getting Length and Character of String

Working with Text: Getting Length and Character of String

Learn about common data types for working with text, including char, string, StringBuilder, and Regex.

One of the other most common types of data for variables is text. The most common types in .NET for working with text are shown in the following table:

Namespace

Type

Description

System

Char

Storage for a single text character

System

String

Storage for multiple text characters

System.Text

StringBuilder

Efficiently manipulates strings

System.Text.RegularExpressions

Regex

Efficiently pattern-matches strings

Getting the length of a string

Let’s explore some common tasks when working with text; for example, sometimes we need to find out the length of a piece of text stored in a string variable:

...