如何从字符串组中获取字符串 [英] how to get the string out of group of string

查看:134
本文介绍了如何从字符串组中获取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如果我有这样的字符串

asd; dfrt; dfrthu; dfrtyhu; are; adchj



asdacasd; xczxdd; saewxasd; cccced; xasdsds; sdasdsad



i希望字符串位于第3和第5位上面给出的字符串。

表示这个字符串

dfrthu和是来自第一个字符串







来自第二个字符串的saewxasd和xasdsds请帮帮我..
我的Winform应用程序的

hi

if i have a string like this
asd;dfrt;dfrthu;dfrtyhu;are;adchj
or
asdacasd;xczxdd;saewxasd;cccced;xasdsds;sdasdsad

i want the string placed at 3 rd and 5th position of the above given string.
means this string
"dfrthu" and "are" fromm the first string

and

"saewxasd" and "xasdsds" from 2nd string please help me..
for my Winform application

推荐答案

像这样:

Like this:
string s = "asd;dfrt;dfrthu;dfrtyhu;are;adchj";
char[] sep = new char[] { ';' };
string[] array = s.Split(sep);
Debug.WriteLine(s[2]); // will print the 3rd element of the array to debug console -> dfrthu
Debug.WriteLine(s[4]); // will print the 5th element of the array to debug console -> are





希望这有帮助。



Hope this helps.


这篇关于如何从字符串组中获取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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