C # Replace character replacement functions

 

 

 It can be replaced with a string of characters in the other character, it can be nested, as follows:

 

 

 It should be noted that it can be replaced with a blank character, but can not replace the null character, when uncertain whether the string is empty, you can make the following judgment, then replace:

 

 Complete code sample:

string aa="d";
if (aa=="d")
{
Console.WriteLine(aa.Replace("d", "a"));
}

//string b = aa.Replace(".", "").Replace("officeword", "doc").Replace("gw", "other") == "" ? "other" : aa.Replace(".", "").Replace("officeword", "doc").Replace("gw", "other");
// Console.WriteLine(b);

Guess you like

Origin www.cnblogs.com/myka/p/11988524.html