码迷,mamicode.com
首页 > 其他好文 > 详细

相关方法扩展

时间:2015-11-17 12:24:15      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
/// <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

 

相关方法扩展

标签:

原文地址:http://www.cnblogs.com/donchen/p/4971190.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!