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)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345