AppendIfNotContains string helper method

I've created a helper function, that allows me to set extra CSS class name(space separated)
public static string AppendIfNotContains(string str, string sToAppend, string delimeter)
            {
                if (!str.Contains(sToAppend))
                {
                    str = AppendWithDelimeter(str, sToAppend, delimeter);
                }
                return str;
            }
public static string AppendWithDelimeter(string str, string sToAppend, string delimeter)
            {
                if ((!str.EndsWith(delimeter) & !String.IsNullOrEmpty(str)) & !String.IsNullOrEmpty(sToAppend))
                {
                    str = str + delimeter;
                }
                str = str + sToAppend;
                return str;
            }

posted @ Sunday, March 02, 2008 3:00 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 2 and 8 and type the answer here:
 

Live Comment Preview:

 
«September»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011