您可以使用 < a href=" "http://msdn.microsoft.com/ en- us/library/dd992421.aspx" rel = “ no follown noreferr"\\ code>String. Join (实际上采用了 IEnumberable<T>
超载) :
String joined = String.Join("", yourArray);
为何我不知道如何将字符串放在文字中?
您可以使用 < a href=" "http://msdn.microsoft.com/ en- us/library/b1csw23d.aspx" rel = “ 不跟随 noreferr"\\ code>String. Format 来构建文本并增加可读性 :
var inserted = page[i].ToString();
var allInserted = String.Join("", yourArray);
var pageFault = pf.ToString();
var itemText = String.Format("After Inserting ({0}) {1} page fault = {2}"
,inserted, allInserted, pageFault);
listBox2.Items.Add(itemText);
<% 1 > 编辑 2 % 1 > :
can i replace some Character instead one number in array? my array :
{1,2,3,4,-1"} output : 1,2,3,4,empty
是的, 您可以替换输出 :
String.Join("", yourArray.Where(i => i != -1));
<% 1 > 编辑 3 % 1 > :
i understand how i can exclude -1 but i didn t understand how i can
replace something with that...like "empty" instead -1
在这里,我们走了...
String.Join(", ", intArray.Select(i => i == -1 ? "empty" : i.ToString()));