{"id":274,"date":"2017-03-10T14:55:24","date_gmt":"2017-03-10T14:55:24","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=274"},"modified":"2025-03-28T16:30:20","modified_gmt":"2025-03-28T16:30:20","slug":"encodedecode-strings","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/strings\/encodedecode-strings","title":{"rendered":"Encode\/Decode Strings"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">HtmlEncode<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Enabling HttpUtility for projects<\/h5>\n\n\n\n<p>By default your app probably can&#8217;t see &#8220;System.Web.HttpUtility&#8221;. &nbsp;You need to include a reference to System.Web.<\/p>\n\n\n\n<p>Right-click your project in the Solution Explorer &gt; Add Reference &gt; Assemblies &gt; Framework &gt; Scroll to System.Web and enable it<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Comma separated strings<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Convert comma separated string to a list<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tsTemp = \"Something,Something Else,Hello\";\n\tif (sTemp.EndsWith(\",\"))\t\t\/\/Remove any trailing comma (will create a blank List entry if present)\n\t\tsTemp = sTemp.TrimEnd(',');\n\tList&lt;String> Values = sTemp.Split(',').ToList();<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Convert a list to a comma separated string<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tList&lt;string&gt; Values = new List&lt;string&gt;{\"Something\",\"Something Else\",\"Hello\"};\n\tMyString = string.Join(\",\", Values);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>HtmlEncode Enabling HttpUtility for projects By default your app probably can&#8217;t see &#8220;System.Web.HttpUtility&#8221;. &nbsp;You need to include a reference to System.Web. Right-click your project in the Solution Explorer &gt; Add Reference &gt; Assemblies &gt; Framework &gt; Scroll to System.Web and enable it Comma separated strings Convert comma separated string to a list Convert a list [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-strings"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":1378,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/274\/revisions\/1378"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}