I want convert this VB.net snippet to C#
sURL = Replace(sURL,"%F9","%C3%B9",,,CompareMethod.Text)
Which one of these is better?
sURL = Strings.Replace(sURL,"%F3","%C3%B3", 1, -1, CompareMethod.Text);
sURL = Regex.Replace(sURL,"%FA","%C3%BA",CompareMethod.Text);
Regex replace is used for Regular expressions. Here you haven't regular expression, so it's better to use usual replace:
sURL = sURL.Replace("%F3","%C3%B3");
I simple String.Replace will be more efficient than Regex.Replace when you are doing a straightforward text-replace. If you don't need any of the features of Regex, it's best not to use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With