Foreach 不迭代值

问题描述

我正在开发一个应用程序,我必须在数据库中的每台机器上执行一些更新操作。每台机器都有一个唯一的 ID。然后还有一个区号,几台机器都在这个区号下。区号也是唯一的。我正在从数据库中读取这些 ID 并将它们存储在一个列表中,然后我想使用这些 ID 一个一个地访问 API。 API 会给我一个响应,我必须相应地阅读和更新数据库。我正在使用 foreach,但我不知道我在做什么错误,它没有迭代到列表的第二个元素(第二个 id),而且我无法使用第二个 ID 调用函数来命中 API。

public static void ProcessIds(string areacode1,string areacode2)
{
    // this is working fine I am getting correct values
    List<IntermediateAPIRequest.IntermediateIds> Ids = 
                                              GetIntermediateIDList(areacode1,areacode2); 
    
    APIRequest apiRequest = new APIRequest();
    foreach (IntermediateAPIRequest.IntermediateIds id in Ids)
    {

       //code for creating API request--this Now fetches the 1st Id from
       // the list and creates the request

        APIresponse result = GetAPIResponsePerID(URL,id.machineID,apiRequest);

        //Code for dealing with the response,for the time being I am 
        // simply displaying it onto the console. 
     } // end of foreach loop
}

我能够正确阅读回复。主要问题是我无法使用列表中的第二个值调用 api。

如果我需要添加更多代码以进行澄清,请告诉我。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)