This article describes the differences and use of the Escape Character (\) and Date Separator (/) Custom Format Specifier in LightSwitch Visual Studio 2012.
This article describes the differences and use of the Escape Character ("\") and Date Separator ("/") Custom Format Specifier in LightSwitch Visual Studio 2012.Escape Character ("\") Custom Format SpecifierThe Escape Character in a format string is interpreted as a custom format specifier instead of a literal character. To prevent the character from being interpreted as a format specifier you can precede it with a backslash (\), in other words with an escape character.Date Separator ("/") Custom Format SpecifierThe "/" Custom Format Specifier is also known as the Date Separator for separating years, months and days. This date separator is retrieved from the DateTimeFormatInfo.DateSeparator property.Note: Suppose the "/" format specifier is used without any other custom format specifiers, then it is interpreted as a standard date and time format specifier and will throw a FormatException.Use the following procedure to create a sample showing how to use the Escape Character("\") and Date Separator("/") Custom Format Specifier on a Screen.Step 1Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.Right-click on "Data Sources" and choose "Add Table".The table appears in the Table Designer window. Insert the records in the following table.Step 2Now once again go to the Solution Explorer, right-click on Screens and choose Add Screen option.The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, inside screen information, choose "Employee" under screen data and provide some name to the Screen and click the "OK" button.The Screen Designer appears as shown below.Press F5 to run the application. Provide the information; we will get the following output. Step 3Escape Character("\") Custom Format Specifier Now stop debugging the application. From the Table Designer select the "DOJ" record as shown in the figure below.Then go to the Format Pattern of Property window in the Table Designer and enter "h\h" in the format pattern for Escape Character Format Specifier as shown below.Once again press F5 to run the application. This time we will get the following output.Step 4Date Separator ("/") Custom Format SpecifierOnce again stop debugging the application and select the "DOJ" record from the table.Now go to the Format Pattern of Property window in the Table Designer and this time enter "MM/dd" in the format pattern for Date Separator Format Specifier as shown below.Once again press F5 to run the application. This time we will get the following output.
Printing in C# Made Easy