首页 > 其他 > 详细

相关方法扩展

时间:2015-11-17 12:21:34      阅读:204      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!