C# 拆分字符串? [英] C# Splitting Strings?

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

问题描述

只是想知道例如,如果我有字符串:

just wondering for example, if I had the string:

Hello#World#Test

我将如何删除 # 然后在三个单独的字符串中包含 HelloWorldTest,例如调用:String1String2String3

How would I remove the # and then have Hello, World and Test in three seperate strings, for example called: String1 and String2 and String3

推荐答案

你可以把它们放在一个字符串数组中,做一些像这样简单的事情:

You can have them in an array of strings doing something as easy as this:

string[] s = "Hello#World".Split('#');

s[0] 包含Hello",s[1] 包含World"

s[0] contains "Hello", and s[1] contains "World"

有关拆分的更多信息,请参见此处:http://msdn.microsoft.com/en-us/library/b873y76a.aspx

See here for more information on split: http://msdn.microsoft.com/en-us/library/b873y76a.aspx

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

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