zoukankan      html  css  js  c++  java
  • HttpUtility.HtmlEncode 方法

    地址:https://docs.microsoft.com/zh-cn/dotnet/api/system.web.httputility.htmlencode?redirectedfrom=MSDN&view=netframework-4.8#overloads

    代码示例:

    using System;
    using System.Web;
    using System.IO;
    
    class MyNewClass
    {
        public static void Main()
        {
            Console.WriteLine("Enter a string having '&', '<', '>' or '"' in it: ");
            string myString = Console.ReadLine();
    
            // Encode the string.
            string myEncodedString = HttpUtility.HtmlEncode(myString);
    
            Console.WriteLine($"HTML Encoded string is: {myEncodedString}");
            StringWriter myWriter = new StringWriter();
    
            // Decode the encoded string.
            HttpUtility.HtmlDecode(myEncodedString, myWriter);
    
            string myDecodedString = myWriter.ToString();
            Console.Write($"Decoded string of the above encoded string is: {myDecodedString}");
        }
    }

    总结:文档演示了,HttpUtility.HtmlEncode方法,将字符串编码成了什么。

  • 相关阅读:
    System 类的使用
    StringBuffer 与 StringBuilder类的使用
    String 类 的 使用
    多线程
    音乐播放
    数据库
    表示图编辑
    UITextView(2)
    UITextView
    tarBar
  • 原文地址:https://www.cnblogs.com/Tpf386/p/11906680.html
Copyright © 2011-2022 走看看