C# System.IO.File Class

The System.IO.File class is a static class that exposes methods to manipulate an existing file in a directory. Such methods allow you to create, delete, open, move or copy a file.  As…

Absolute and Relative Paths

Files and directories can be uniquely identified using their path names. Path  names specify where files and directories are located. When specifying path  names, you can either use an absolute…

C# File System

Most of the time, you will need to be able to write your data to files for permanent storage. You will also need to be able to access the file…

C# Regular Expressions

Sometimes when getting input from the user, you need to check if it follows a certain pattern. For example. consider a textbox that expects to get an email from the…

C# StringBuilder

The System.String class can use the + operator to concatenate two strings. But this is inefficient when concatenating two different strings. The reason is that String objects in .NET are immutable, that is, the value cannot…

String Formatting

.NET provides you with ways to format the output of strings. You can use the String.Format to format your strings using different format specifiers. string str1 = "This"; string str2 = "That";…

Changing the Casing of Strings

You can change the casing of a string. For example, a string composing of lowercase letters can be transformed into all caps. We use the ToUpper() and ToLower() instance methods which returns an uppercase…

Searching Strings

Searching strings have been made easy thanks to the different methods provided by .NET. Let's take a look at the different methods to find the occurrence of a particular string.…

Splitting Strings

If you want to split a string into multiples strings, you can use the Split method. Let's take a look at the different overloads of the Splitmethod. The Split method returns a string array that…

Trimming Strings

Sometimes, a user types unnecessary spaces that may cause certain errors. When accepting strings from a user, especially if the input came from a text box or similar controls, have…

Inserting Strings

.NET provides you with the Insert instance method that allows you to insert strings into existing strings. For example, If you have a string "Hello World!", you can insert the string "Happy…

Concatenating Strings

There are several ways of concatenating strings. Concatenating simply means combining multiple strings into one. In C#, the simplest way to concatenate strings is by using the + operator as shown below.…

Comparing Strings

We can compare two strings for equality using several ways. For example, we can use the == operator to test if the two strings are equal. The == operator doesn't compare their references, but…