The string type

Single characters are not much fun on their own but, when put together, they constitute a powerful communication tool. The string type does exactly this for us, providing a powerful means of representing and working with strings of characters. strings are consequently used in most of your programs for names, descriptions, addresses, headings, and so on.

The word string is an alias for the .NET Framework class String located in the System namespace. Whenever you declare a variable to be of type string, you are, in fact, specifying this variable to be able to hold a reference to a System.String object, which then encapsulates your text. Consequently, the following two lines of source code have exactly the same meaning.

The string ...

Get C# Primer Plus now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.