62,047
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
string yourStr = "**************";
string oldStr = "xabada";
if (oldStr.IndexOf('a') > -1)
{
oldStr = oldStr.Remove(oldStr.IndexOf('a'), 1).Insert(oldStr.IndexOf('a'), yourStr);
}
Console.WriteLine(oldStr);
}
string test = "xabada";
test = Regex.Replace(test, @"(?<=^[^a]*)a", "*");
string test = "xabada";
int index = test.IndexOf("a");
if (index > -1)
{
test = test.Remove(index, 1).Insert(index, "*");
}