Thursday, February 6, 2014

C# Session Wrapper

The following C# class is a simple implementation of a wrapper class for sessions. It allows getting, setting and removing of objects (of  a defined type) from the session.

C# Is Email Function

The following snippet is handy when validating if a given string is an email address.
public static bool IsEmail(string emailAddress)
            Regex isEmail = new Regex(@"\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$");
            Match m = isEmail.Match(emailAddress);
            return m.Success;