Chomping At The Bits

Helper Classes

Trust me when I say I’m no stranger to abusing repeat methods in code behinds… however, it does reach a point where something has to give. When you reach that point, your solution is a ‘helper’ class.

Below is a quick/basic example of how to get started with helper classes.
In my solution, I created a folder called ‘Helpers’ and added a new class object called ‘StringManip’.
Once that was completed, I added a few methods like:

public static string UpperString(string val)
{ return val.ToUpper(); }

In my code behind, I reference the class through a using statement:

using HelperClass.Helpers;

And then I can call the methods:

lbl_aspnet.Text = StringManip.UpperString(lbl_aspnet.Text);

If the above isn’t enough to get you rolling…. then download the demo solution by Clicking Here