我想将一个字符串拆分成一个数组。字符串如下:
:hello:mr.zoghal:
我想将其拆分如下:
hello mr.zoghal
我试过了...
string[] split = string.Split(new Char[] {':'});
现在我想要:
string something = hello ;
string something1 = mr.zoghal;
我怎样才能做到这一点?
最佳答案
String myString = ":hello:mr.zoghal:";
string[] split = myString.Split(':');
string newString = string.Empty;
foreach(String s in split) {
newString += "something = " + s + "; ";
}
您的输出将是: 某事=你好;某事= Zoghal 先生;
关于c# - 如何将字符串拆分为数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1203966/