在String数组中插入一个元素 [英] Insert a element in String array
本文介绍了在String数组中插入一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有包含n个元素的字符串.
I have string containing n elements.
我想在第一个位置插入一个自动递增的数字.
I want to insert a automatically incremented number to the first position.
例如数据
66,45,34,23,39,83
64,46,332,73,39,33
54,76,32,23,96,42
我正在使用分割字符','将其分割为字符串到数组
I am spliting to string to array with split char ','
我想要第一个位置的数字递增的结果数组
I want resultant array with a incremented number a first position
1,66,45,34,23,39,83
2,64,46,332,73,39,33
3,54,76,32,23,96,42
请提出我该怎么做.
谢谢
推荐答案
您不能使用数组,而需要使用 List< string>
.
You can't with an array, you need to use a List<string>
instead.
例如:
List<string> words = new string[] { "Hello", "world" }.ToList();
words.Insert(0, "Well");
这篇关于在String数组中插入一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文