我有一個List<String>
其中包含值如Char:Char_Number1_Number2
。 我想找到索引或替換值,通過搜索Number1_Number2
,組合Number1_Number2
始終是唯一的。列表<String>查找並替換字符串的一部分值
EG:B:S_4_0將被替換爲B:S_5_1,但搜索的標準是4_0
B:S_4_0
B:N_1_2
A:N_3_3
B:N_0_0
A:S_2_5
A:S_3_4
我想這些任務
- 如何找到索引或使用字符串的後半部分的完整值
- 如何更換或使用字符串下半年
int index = Player1.IndexOf("5_6"); // Find Index
Player1[index]="5_6"; // Replace value
Player1.Remove("5_6"); // Remove
參考
How to replace some particular string in a list of type string using linq
How to replace list item in best way
刪除一個特定的值
** B:S_4_0 **將被替換爲** B:S_5_1 ** ,,但是搜索條件是** * 4_0 * –
'num_num'不能轉換爲int。你是否想把它變成字符串鍵? –