相关方法扩展

/// <summary>
    /// string 扩展
    /// </summary>
    public static class StringExtends
    {
        /// <summary>
        /// 用于防止XSS的字符串转义
        /// </summary>
        /// <param name="txt"></param>
        /// <returns></returns>
        public static string SRUrlEncode(this string txt)
        {
            if (string.IsNullOrWhiteSpace(txt))
            {
                return txt;
            }

            return StringEncode.HtmlEncode(HttpUtility.UrlDecode(txt));
        }

        /// <summary>
        /// 判断字符串是否为空(null)或是内容为空
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this string str)
        {
            return string.IsNullOrEmpty(str);
        }
    }
View Code

 

posted on 2015-11-17 11:34  donchen-c  阅读(169)  评论(0编辑  收藏  举报