How do I print “1” as “0001” ?

Yep, a nice little question. Some of you may have wondering how to do that. In my database ID field it says “1” (or any integer value) on my Web Page or Windows Form I need to print this as “0001”. Do we have a simplest method to do that? And the answer is (drum roll) ….. YES ..

OK, next question what does this format specifier “D” means. Here is the MSDN help about it.

The “D” (or decimal) format specifier converts a number to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. This format is supported only for integral types.

The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. If no precision specifier is specified, the default is the minimum value required to represent the integer without leading zeros.

Also we can use another string method known as . Lets have a look on that code.

allows you to apply any character (type of Char) as the leading character. In this case ‘0’

Have Fun 🙂

Where did they hide the web templates in Visual Studio 2013

For the first time when I loaded the Visual Studio 2013, just clicked on the “Web” label in the right side pane under Templates in dialog window, just felt OK where are my web templates.

New Project

OK, to get those now you need to go through one extra step. Just select on the Label “ASP.net Web Application”  and choose a folder and give a proper name to your project and click “OK”. The next dialog box has plenty of information you need know about your web application.

Select Template

1. This area will help you toe select a starter template. It has

Empty – A blank skeleton to start from scratch, You will need to add References, Folders for your project by hand.

Web Forms – A Web Forms project template will be created here. Most of the References you need to work with a Web Project will be loaded for you and all the necessary folders and files created. You will have a basic web site working here, to test just simply press “”.

MVC – This option will create a template with Model, View, Controller pattern. All the required folders, scripts and references will be automatically created for you. A sample web site is already ready for you to test. Simple “” will get you the sample web site up and running.

Web API – This template will allow you to create a RESTful HTTP Service. A broad range of clients will be able to access this service when you are done.

Single Page Application – A template that allows you to create a website with rich client JavaScript, HTML5 and CSS3. With a mix of Web API.

Facebook – A ready to run facebook application will be created with this template. A great template to start your facebook application.

2. An informative area of the selected template on area 1. A small description is displayed here for the selected template.

3. This area will allow you to add references or remove them on a selected template on area 1. If you select add unit testing, you will able to give the name for the testing project name here as well.

4. This button will allows you to select the authentication type of the selected project template type.

Enjoy 🙂