Looping through 2 Lists at once

前端 未结 7 436

I have two lists that are of the same length, is it possible to loop through these two lists at once?

I am looking for the correct syntax to do the below



        
相关标签:
7条回答
  • 2021-01-31 11:23

    I have this small function which helps me to iterate through this two list objects. schema is of type SqlData, which is a class that hold three properties. And data is a list that holds values of dynamic type. First I'm iterating through the schema collection and than using the index of item to iterate through the data object.

    public List<SqlData> SqlDataBinding(List<SqlData> schema, List<dynamic> data)
    {
        foreach (SqlData item in schema)
        {
            item.Values = data[schema.IndexOf(item)];
        }
        return schema
    }
    
    0 讨论(0)
提交回复
热议问题