There are often cases when you need to format a string or number into a string with a specified length. SQL Server 2008 doesn't have an inbuilt "PAD" function, but you can get around that with some String functions.

For example, you want to format an integer value into a 6-digit string, where the integer is of variable length, and any missing digits must be padded with a '0'. In SQL Management Studio, run the following script to generate some test data:

I've been using XBMC at home, and I've been trying to find software to edit Genres on my movie files so I can sort them a little better. To my surprise, I couldn't find anything that seems to be able to edit tags on all the file types that I used. My next step was looking for libraries, and I was pleasantly surprised with taglib-sharp - available at https://github.com/mono/taglib-sharp.

I installed using the Nuget Package Manager in Visual Studio, and it literally took me 2 minutes to figure out a basic example and it worked perfectly on a number of files I tried!

One of the challenges when creating web applications is the separation of logic between the client and the server. Most solutions will have the concept of "lookups" e.g. categories or some type of data that is static but necessary for the business logic. In terms of the server-side code, you will usually reference these using enums or constants, so they are not scattered throughout your solution in code.

However, you often will need to execute logic on the client using these same lookup values. This means you need to declare them again, which can result in the client and the server-side code going out of sync if the lookups change. One nice way to tackle this if you're using Visual Studio is with the use of T4 templates.

Example

You have an "Animal" class declared in your C# project and you want some of the const values exposed on the client.