I’ve always felt that the string is the most noble of data types. Computers run on ones and zeros, sure, but people don’t. They use words, sentences, and paragraphs to communicate. People communicate with strings. The meteoric rise of HTTP, HTML, REST, serialization, and other heavily string-oriented, human-readable techniques vindicates—at least in my mind—my lifelong preference for the humble string.
Of course, you could argue that, as we have so much computing power and bandwidth available today, passing friendly strings around in lieu of opaque binary data is actually practical and convenient. But I wouldn’t want to be a killjoy.
Guess what my favorite new .NET 2.0 feature is. Go ahead—guess! Generics? Nope. Partial classes? Nope again. It’s the String.Contains method. And I’m awfully fond of String.IsNullOrEmpty, too.
What I love most about strings is that they have a million and one uses. They’re the Swiss Army Knife of data types.
Regular expressions, for example, are themselves strings:
RegEx = “<[a-z]|
SQL queries are strings, too:
Sql = “SELECT * FROM Customers WHERE State = ‘NY’
ORDER BY ZipCode”;
Regular Expressions and SQL are mini-languages that wield considerable power—all inside a humble string. I love strings, and so should you. The String class is an integral part of any programmer’s toolkit—mastering it is essential.