C#: String Operations

Please see my other C# articles.

Performing common string operations.

The .NET Framework is essential a huge repository of reusable classes that provide robust functionality organized by various namespaces.
For example, the String namespace allows developers to easily and safely manipulate strings in a variety of ways.

First, I’ll show I perform such basic string operations using my name.

1-string-operations 1-string-operations-exe

When needing to work with special characters, simply use one of the many literal to control layout of the strings.

2-string-operations 2-string-operations-exe

Also, it’s very simple to build strings out of other strings.

3-string-operations 3-string-operations-exe

Comparing string value is another useful tool provided by the String namespace.

4-string-operations 4-string-operations-exe

It’s important to remember the immutability of String objects as illustrated by this example.

5-string-operations 5-string-operations-exe

While technically in the Text namespace, StringBuilder provides a very light weight alternative when using strings in scenarios where very little functionality is needed.

6-string-operations 6-string-operations-exe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s