Removing char in string from specific index

前端 未结 5 914
情话喂你
情话喂你 2021-02-18 14:25

Is there any function in C# that remove from string on specific index, for example

string s = \"This is string\";

s.RemoveAt(2);

s is now \"Th

5条回答
  •  粉色の甜心
    2021-02-18 14:33

    You could use Regular Expressions also.

    Console.WriteLine(Regex.Replace("This is string", @"(?<=^.{2}).", ""));
    

    This would remove the third character from the start.

    DEMO

提交回复
热议问题