What is an escape sequence? Well, put simply, an escape sequence is a series of special characters which are interpreted by the compiler as a command. In other words, they suspend the normal processing to perform some special function.
In C#, escape sequences are represented by a ‘\’ (backslash) followed by a letter or a combination [...]
I have added a new page to this blog called ASCII Codes, which can be accessed from the navigation bar at the top of the page. This new page is intended as a reference guide which you can use to look up an ascii code’s decimal, hexadecimal, and html values. There is also a description [...]
In this post I am going to show you a few different ways how you can format a decimal number (float, double, or decimal).
Setting the Maximum Allowed Decimal Places
To format your numbers to a maximum of two decimal places use the format string {0:0.##} as shown in the below example:
string.Format(“{0:0.##}”, 256.583); // “256.58″
string.Format(“{0:0.##}”, 256.586); // [...]
In this post I am going to show you a few different ways how you can format an integer (int).
Padding with Zeroes
To pad your integer with zeroes write your format string with a colon (‘:’) and include as many zeroes as you wish after the colon ({0:[your zeroes]}). Below are a few examples.
string.Format(“{0:00000}”, 123); [...]
In this post I have listed the different formatting options provided by .NET for a DateTime object.
The examples shown below are based on the following DateTime object:
// 18 September 2009 20:10:35
DateTime dt = new DateTime(2009, 09, 18, 20, 10, 35, 123);
[...]