A copy constructor is a constructor that creates a new object by making a copy of an existing object. ICloneable is a standard interface that you can implement, whereby you’ll add a Clone method to your class. The purpose of…Continue Reading →
I’ve been heavily working with generics over the past few weeks for the final re-factor of LiveFlex. Generics are fantastic but they do have some annoying limitations. You can’t, for instance, create a List<T> and add mixed types such as…Continue Reading →
I used to often find myself creating utility classes to process enums to create markup or carry out particular actions based on the enum value. Since extension methods have been introduced I have started using them to add processing methods…Continue Reading →
Here is a very simple asp.net .Closest() function like the jquery one. public static class ControlExtensions { public static Control Closest(this Control control, Type type ){ Control closest = null; Control parent = control.Parent; while(closest == null && parent != null){ if(parent.GetType().ToString() == type.ToString()){ return parent; } parent = parent.Parent; } return null; } }
I am trying to keep a list of the last 10 pages a user has been too. I tried to use Stack but it doesn’t support a fixed length so here is a dirty little class to only keep the…Continue Reading →
When you’ve been working heavily with c# for a few days, coalesce jumps into your head for a lot of c# issues. Heres a little helper to provide coalesce in .net /// <summary> /// Returns the first non null value,…Continue Reading →