小编swt*_*h3k的帖子

将当前Collection <T>保存在循环中

我在收藏清单方面遇到了一些问题.我使用该列表来保存我从xml和textfiles收集的一些客户数据.

// First i create an instance of the list  
List<Customer> cusList = new List<Customer>();
// Save files
String[] somefiles = Directory.GetFiles(//FromPath");

// Then i loop through some files and collect data for the list
for (int i=0; i<somefiles.length; i++)
{
    if (some statements match)
    {
        // call a methode and save file data to the cuslist
        cuslist= callmethode(somefiles);
    }
    else 
    {
     System.Console.WriteLine("Do nothing");
    }
 }
Run Code Online (Sandbox Code Playgroud)

我想扩展所有文件的列表,但目前我只得到循环数据来自最后一个文件.

我如何处理它,它保存所有文件中的所有数据?

亲切的问候

c# collections

-1
推荐指数
1
解决办法
89
查看次数

标签 统计

c# ×1

collections ×1