-3

I need an example to encode: abcdef into: %61%62%63%64%65%66.

The only way I found of doing this is on this website: http://scriptasylum.com/tutorials/encode-decode.html

But how can I do this in C# manually.

Shaishav Jogani
  • 2,111
  • 3
  • 23
  • 33

1 Answers1

0
string TextToEncode= "abcdef";
var encodedText = "%" + string.Join("%", from c in TextToEncode select ((int)c).ToString("X"));

//encodedText  = %61%62%63%64%65%66
  • While this code may answer the question, providing additional [context](https://meta.stackexchange.com/q/114762) regarding _how_ and/or _why_ it solves the problem would improve the answer's long-term value. Remember that you are answering the question for readers in the future, not just the person asking now! Please [edit](http://stackoverflow.com/posts/433015618/edit) your answer to add an explanation, and give an indication of what limitations and assumptions that apply. – Dev-iL Apr 09 '17 at 15:52