C# 使用Split方法以制表符( )分割字符串
在C#中,可以使用字符串的Split方法来将字符串按指定的分隔符拆分成多个子串。如果要以制表符\t作为分隔符,可以将其作为参数传递给Split方法。\n\n以下是一个示例代码:\n\ncsharp\nstring input = "Hello\tWorld\tC#\tSplit";\nstring[] substrings = input.Split('\t');\n\nforeach (string substring in substrings)\n{\n Console.WriteLine(substring);\n}\n\n\n运行上述代码将输出以下结果:\n\n\nHello\nWorld\nC#\nSplit\n\n\n在上述示例中,我们首先定义了一个包含制表符的字符串input。然后,我们使用Split('\t')方法将该字符串按制表符拆分成多个子串,并将结果存储在字符串数组substrings中。最后,我们使用foreach循环遍历substrings数组,并将每个子串打印到控制台上。
原文地址: https://www.cveoy.top/t/topic/pTRZ 著作权归作者所有。请勿转载和采集!