.net - 我可以在不引用 Microsoft.VisualBasic 的情况下以 c# VB6 样式拆分字符串吗?

标签 .net .net-3.5 c#-3.0

不幸的是,似乎没有string.Split(string separator),只有string.Split(char separator)。

我想根据多字符分隔符(如 VB6)拆分我的字符串。在 c# 中是否有一种简单的方法(即,不是通过引用 Microsoft.VisualBasic 或必须学习 RegExes)来执行此操作?

编辑:使用 .NET Framework 3.5。

最佳答案

String.Split() 有其他重载。其中一些采用 string[] 参数。

string original = "first;&second;&third";
string[] splitResults = original.Split( new string[] { ";&" }, StringSplitOptions.None );

关于.net - 我可以在不引用 Microsoft.VisualBasic 的情况下以 c# VB6 样式拆分字符串吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/154706/

相关文章:

c# - ASP.NET MVC : How to reliably get the real URL of the current request?

使用 7zip 的 C# 归档,一直卡在通配符调用上

c# - 以编程方式使用附加字段扩展 Lucene 文档

.net - 在键/值集合中使用 List<T> 的最佳方法?

c# - 从 XML 反序列化对象时出现间歇性错误

c# - IDE中的Visual C#Express Edition命令行参数

c# - 我可以检查子序列是否比 O(n*n) 更快

.net-3.5 - .NET 3.5 运行时和 .NET 4 运行时兼容性

xna - DrawUserIndexedPrimitives 用于单独的网格

c# - 如何使用 addHandler 引发事件