Encode/Decode

 #region Encode/Decode
  
  public static string HtmlDecode( String textToFormat )
  {
   if ( IsNullorEmpty ( textToFormat ) )
    return textToFormat;
   return System.Web.HttpUtility.HtmlDecode ( textToFormat );
  }

  public static string HtmlEncode( String textToFormat )
  {
   if ( IsNullorEmpty ( textToFormat ) )
    return textToFormat;
   return System.Web.HttpUtility.HtmlEncode ( textToFormat );
  }

  public static string UrlEncode( string urlToEncode )
  {
   if ( IsNullorEmpty ( urlToEncode ) )
    return urlToEncode;
   return System.Web.HttpUtility.UrlEncode ( urlToEncode );
  }
  public static string UrlDecode( string encodeUrl )
  {
   if ( IsNullorEmpty ( encodeUrl ) )
    return encodeUrl;
   return System.Web.HttpUtility.UrlDecode ( encodeUrl );
  }
  #endregion

原文地址:https://www.cnblogs.com/jimmychow/p/2353606.html