Commonly Used String Methods

Throughout this exploration of the framework’s rich functionality to deal with text, we have barely spoken about the type it’s all about: System.String. Let’s spend a minute or two pinpointing a few useful methods of this class.

Strings are Character Sequences...

And because sequences are implemented using the IEnumerable<T> interface, guess what? The whole set of query operators defined over IEnumerable<T>, here with T substituted for char, shows up in the IntelliSense on a string object. This can be perceived as annoying at times. In fact, prior to Visual Studio 2010, for some reason I don’t understand, IntelliSense on string objects never showed the extension methods.

Obviously, this behavior can be suppressed ...

Get C# 4.0 Unleashed 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.