我试图将循环中的值存储在列表中。我的代码是:使用For循环将值存储在列表中
int count = 100;
for(int i=0;i<=count;i++)
{
my code to get the text:
m.gettextfromelement("xpath");
}
需要的代码存储在一个列表
我试图将循环中的值存储在列表中。我的代码是:使用For循环将值存储在列表中
int count = 100;
for(int i=0;i<=count;i++)
{
my code to get the text:
m.gettextfromelement("xpath");
}
需要的代码存储在一个列表
这是做这件事......值
var stringList = new List<string>(); // The list to store your text
var count = 100;
for (var iteration = 0; iteration <= count; iteration++)
{
//Code to get the text...
//Code to get the specific element - var specificElement = m.gettextfromelement("xpath");
//Finally, you "Add()" the specific element text to the list as...
stringList.Add(specificElement);
}
所有数据结构在C#中使用在MSDN网站上可用。列表的页面是this,FYI。 dotnetpearls是我经常访问的C#的另一个网站。
var list = new List<string>();
int count = 100;
for(int i=0;i<=count;i++)
{
list.Add(m.gettextfromelement("xpath"));
}
问题不清楚.... –
errr ....'List.Add'?你是否尝试过研究任何东西? – BradleyDotNET
我想从列表中的列表中保存文本(国家),然后根据字母顺序对其进行排序。 我正在使用for循环来获取这些值,但卡住了如何将该值存储在列表或集合中 – Syed