public class Example { public static void Main() { string source = "I am stronger than Batman."; string toRemove = "stronger "; string result = string.Empty; int i = source.IndexOf(toRemove); if (i >= 0) { result = source.Remove(i, toRemove.Length); } Console.WriteLine(source); Console.WriteLine(result); } }
원문링크 : [C#/General] 텍스트 제거 (String.Remove)