Convert VB.net to C #

I want to convert this VB.net fragment to C #

sURL = Replace(sURL,"%F9","%C3%B9",,,CompareMethod.Text)

Which one is better?

sURL = Strings.Replace(sURL,"%F3","%C3%B3", 1, -1, CompareMethod.Text);
sURL = Regex.Replace(sURL,"%FA","%C3%BA",CompareMethod.Text);
+3
source share
2 answers

Regex replace is used for Regular expressions . You don't have a regex here, so it's best to use a regular replacement:

sURL = sURL.Replace("%F3","%C3%B3");
+6
source

I simple String.Replacewill be more efficient than Regex.Replacewhen you are doing plain text-replace. If you do not need any functions Regex, it is better not to use it.

+2
source

All Articles