/// <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); } }