wcf 工作流服务应用程序中的 foreach 循环错误

foreach loop error in wcf workflow service application

我有一个包含 3 个服务的工作流,我想自动检查每个输入的条件,所以我使用了一个 foreach 循环来执行此操作,但我遇到了 error.What 我现在应该做什么吗? 这里 error:Cannot 将类型 'UniversityList.StudentInfo' 隐式转换为 'System.Collections.Generic.IEnumerable'。存在显式转换(是否缺少转换?)

the picture is here

new UniversityList.StudentInfo() {NationalKey=san.NationalKey}

由于它是一个 foreach 循环,因此您需要一组项目,而不仅仅是单个项目。您可以通过这样做使单个项目成为一个集合。

new List<UniversityList.StudentInfo>(new UniversityList.StudentInfo[] 
    {
        new UniversityList.StudentInfo
        { 
            NationalKey=san.NationalKey
        }
    })

该列表实现了 System.Collections.Generic.IEnumerable 并且会解决您的错误。