-1
在這裏我想根據分隔符的號碼來建立一個字符串。 我的方案, ListOfWords是ABC | EFG然後建設者爲1/2,但在myone它只顯示1根據分隔符的號碼建立一個字符串
我的C#代碼是
var ListOfWords = "ABC|EFG";
var noOfOfSeperators = ListOfWords.Count(f => f == '|'); // in here it shows me 1
StringBuilder builder = new StringBuilder();
for (int i = 1; i <= noOfOfSeperators; i++) {
builder.Append(i).Append("/"); // i want to show the final result if this is 1/2
}
你面臨什麼問題? –
noOfSeperators + 1? –
@DarrenYoung,更確切地說:'for(int i = 1; i <= noOfOfSeperators + 1; i ++)' –