If I have a string and I want to replace the last character from this string with an asterisk, for example.
I tried this
var myString = "ABCDEFGH";
myString.ReplaceCharacter(mystring.Length - 1, 1, "*");
public static string ReplaceCharacter(this string str, int start, int length, string replaceWith_expression)
{
return str.Remove(start, length).Insert(start, replaceWith_expression);
}
I tried using this extension method, but this will not work. Why is this not working?
source
share