Select Page

ASP.NET MVC 2 ninja tips and tricks

Distilled from Scott Hanselman’s Blog ASP.NET MVC 2 Ninja Black Belt Tips by Scott Hanselman T4 Templating In VS 2010 you can D/L & Install the Tangible T4 editor extension Use the T4MVC templates from MVC Contrib on Codeplex Set the <:MvcBuildViews>...

C# Boxing and Unboxing variables

When using variables in C# you need to be aware of and careful with boxing and unboxing. For example the following code; int discount = 20; object discPerc = discount; discount = 15; int discPercent = (int)discPerc; In this instance the value of discount is 15 but the...

C# Generic classes

You can declare a class with a generic type so that you can later instantiate it specifying the type at that point. public abstract class genericListClass<t> { protected virtual add(T value) { … } } You can then instantiate a GenericListClass for different...

C# Extension Methods

By using the this keyword you can add to (extend) any class, even sealed classes. So public static string ToTitleCase(this string value) { … } allows you to do the following; string state = “south west australia”;...

Auto-implemented Properties (C#)

Previously to add a property to a class would involve creating a private variable to store the value as well as the get and set property accessors to expose it. private string headingFontName; public string headingFontName { get{return headingFontName;}...
%d bloggers like this: