Reputation: 461
How to convert word in string array using System.Web.HttpUtility.UrlEncode as
well also remove it-> "!!*!!"
var array= new string []
{"windows!!1!!","dual+sim!!3!!","32+gb!!2!!","Intel+i5!!2!!","red%2fblue"};
Output array
var Output-array= new string []
{"windows","dual sim","32 gb","Intel i5","red/blue"}
How can do like this in single line of code in C#
Upvotes: 2
Views: 652
Reputation: 45997
It's HttpUtility.UrlDecode
string[] array = new string[] { "windows!!1!!", "dual+sim!!3!!", "32+gb!!2!!", "Intel+i5!!2!!", "red%2fblue" };
string[] result = array.Select(x => System.Web.HttpUtility.UrlDecode(System.Text.RegularExpressions.Regex.Replace(x, @"!!.*!!", "")).Replace("+", " ")).ToArray();
Upvotes: 3