[英]How to split string delimited with “-” into different strings?
I have a string in the following format: 我有一个以下格式的字符串:
string1-string2-string3
I want to be able to get 3 strings out of this. 我希望能够得到3个字符串。 How do I do that? 我怎么做?
string[] words = s.Split('-');
foreach (string word in words)
{
Console.WriteLine(word);
}
使用String.Split :
string[] parts = yourString.Split('-');
你可以使用String.Split: string1.Split('-');
你可以做这样的事情
yorString.Split('-')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.