Working with Strings
Strings in C# correspond to the .NET String type, and there's a great deal of functionality built into them. For example, you can append one string to another with the + operator:
string string1 = "Hello "; string string2 = "there!"; string2 = string1 + string2;
This code leaves "Hello there!" in string2. You can also access the individual characters as if the string were an array, like this:
string string1 = "Hello "; char char1 = string1[1];
This code leaves 'e' in char1 (note that, as in C++, character literals are enclosed in single quotes, like 'e', whereas string quotes are enclosed in double quotes, like "Hello!"). Strings come with many built-in methods as well. For example, take a look at the code in ch02_23.cs, ...
Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.