在C#中拆分多字符 [英] Split Multiple character in C#

查看:69
本文介绍了在C#中拆分多字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在此字符串分割每个单词?

I want to split each words in this string?

我写代码

String s1=" welcome to our website,thanku."
string s2= s1.Split(",-.".ToArray());



但是,这是行不通的。

But this isn't working.

推荐答案

我相信你想拆就空格 - ,然后尝试:

I believe you want to split on space, ,,. and -, then try:

string[] splitArray = s1.Split(',','-','.',' ');

string.Split 返回字符串元素,不是一个单一的字符串元素的数组。

string.Split returns an array of string element, not a single string element.

这篇关于在C#中拆分多字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆