Chapter 3: Pulling Strings

In This Chapter

check.png Pulling and twisting a string with C# — just don’t string me along

check.png Matching similar values

check.png Doing other string operations, such as searching, trimming, splitting, and concatenating

check.png Parsing strings read into the program

check.png Formatting output strings manually or using the String.Format() method

For many applications, you can treat a string like one of the built-in value-type variable types such as int or char. Certain operations that are otherwise reserved for these intrinsic types are available to strings:

int i = 1;          // Declare and initialize an int.

string s = “abc”;   // Declare and initialize a string.

In other respects, as shown in the following example, a string is treated like a user-defined class (I cover classes in Book II):

string s1 = new String();

string s2 = “abcd”;

int lengthOfString = s2.Length;

Which is it — a value type or a class? In fact, String is a class for which C# offers special treatment because strings are so ...

Get C# 5.0 All-in-One For Dummies 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.