HtmlEncode from Class Library

后端 未结 8 1202
情书的邮戳
情书的邮戳 2020-11-29 23:15

I have a class library (in C#). I need to encode my data using the HtmlEncode method. This is easy to do from a web application. My question is, how do I use this method fro

8条回答
  •  执念已碎
    2020-11-30 00:06

    Import System.Web Or call the System.Web.HttpUtility which contains it

    You will need to add the reference to the DLL if it isn't there already

    string TestString = "This is a .";
    string EncodedString = System.Web.HttpUtility.HtmlEncode(TestString);
    

提交回复
热议问题