One of the other most common types of data for variables is text. The most common types in .NET Standard 2.0 for working with text are shown in the following table:
Namespace | Example types | Description |
|
| Storage for a single text character |
|
| Storage for multiple text characters |
|
| Efficiently manipulates strings |
|
| Efficiently pattern-matches strings |
Add a new console application project named WorkingWithText
.
In Visual Studio 2017, set the solution's startup project to be the current selection.
Sometimes, you need to find out the length of a piece of text stored in a string
class.
In Main
, add statements to define a variable to store the name of the city London, and then output its name and length, as shown in the following code:
string city = "London"; WriteLine($"{city} is {city.Length} characters long.");