在C#中,可以使用正则表达式的`Regex.Replace`方法来删除字符。下面是一个示例代码,演示如何使用正则表达式删除字符串中的字符: ```csharp using System; using System.Text.RegularExpressions; class Program { static void Main() { string input = "Hello, World!"; string pattern = "[aeiou]"; // 删除所有元音字母 string result = Regex.Replace(input, pattern, ""); Console.WriteLine(result); // 输出: Hll, Wrld! } } ``` 在上面的示例中,我们使用正则表达式`[aeiou]`来匹配所有的元音字母,并使用空字符串替换它们,从而删除了字符串中的元音字母。