A Guided Garden Stroll through the .NET Framework Class Library

Namespace: SYSTEM.TEXT

● I am the Text Namespace. Use my various Encoder and Decoder classes to convert between Unicode characters and other types of target character code pages.

For example, you can use my ASCIIEncoding.GetBytes method to convert a byte array containing ASCII characters into a Unicode Character Array.

My most famous class, however, is the StringBuilder* class. Because the .NET native string data type is immutable, meaning, once established, it can never be changed, it is important to know about the StringBuilder class.

If, in your code, you find yourself concatenating a series of string constants and string variables to make one long string, like when you are creating a SQL query statement, you could be forcing your application to consume and release a lot of memory forcing the Garbage Collector to work overtime. Each time you are "changing" a string variable, behind the scenes, .NET is creating a new memory space to hold the entire "new" string and releasing the old.

The StringBuilder is built for efficient string concatenation. If you like, you can specify an approximate amount of memory to allocate when it is first constructed. As you append new strings to the string builder and it runs out of memory, it will automatically find new memory for it to continue its work.

To use the StringBuilder, repeatedly call it’s Append method. To get the string back out, simply call the standard ToString method. To reuse an existing StringBuilder, simply set its Length property back to Zero.

System.Text.RegularExpressions* is a very important namespace to know about. Regular Expressions is a computer language unto itself and is used when you need to validate input data, find and replace patterns of characters and has some very powerful functionality for manipulating text.

www.Orbonyx.com