C# Simplified, part 3
(Page 1 of 6 )
In this article you will learn about a variety of useful functionalities in C#. These include various escape characters; differing formats for numbers, dates, and time; arrays; and enumeration.
Files associated with this article can be downloaded here.
C# Simplified covers each and every concept of C# programming language in a concise manner. The articles in this series have been divided into several parts and will provide detailed explanations along with source codes and screenshots. This series has been specifically written for beginners and students with an aim to teach C# in the quickest possible time. Please send your comments to csharpsimplified@gmail.com
Different Types of Escape Characters in C#
C# provides a variety of ways to produce beep sounds when an error occurs, create tabs between words, print output with double quotes and much more. These functionalities can be achieved with the help of the built-in escape characters. Listing 3.1 illustrates each of these characters in detail. I have provided the necessary explanations in the form of comments
Listing 3.1
using System;
class Escape
{
public static void Main()
{
// Prints Welcome with a single beep from your CPU
Console.WriteLine("Single beep sound heard");
Console.WriteLine("\aWelcome");
// Prints elcome after deleting W due to Backspace escape character
Console.WriteLine("W\belcome");
// Prints Wel and Co and me in three lines
Console.WriteLine("Wel\nco\nme");
// Prints Welcome after a single tab position
Console.WriteLine("\tWelcome");
// Returns \Welcome\
Console.WriteLine("\\Welcome\\");
// Returns 'Welcome'
Console.WriteLine("\'Welcome\'");
// Returns "Welcome"
Console.WriteLine("\"Welcome\"");
}
}
The output of the above program looks like Figure 3.1

Figure 3.1
Next: Displaying numbers in different formats >>
More C# Articles
More By Anand Narayanaswamy