0

我目前正在尝试将字典(字符串,字符串)添加到 Ienumerable(字典(字符串,字符串))

看起来很简单,但我找不到答案...如果您需要更好的解释,这是我的代码

Dim actualList As IEnumerable(Of Dictionary(Of String, String))

Dim addRows As New Dictionary(Of String, String)
        addRows.Add("LinkTitle", "Ultimate Test Item")

我想就在这里,我会尝试将 addrows 放入实际列表中,但是我在这样做时遇到了麻烦......

'this sends our custom dictionary to sharepoint
        Dim updateOutput = ListServiceUtility.UpdateListItems(Test_Sharepointsite_url, myCred, Test_List_Name, Nothing, addRows.AsEnumerable, 1)
4

1 回答 1

4

IEnumerable 没有您正在寻找的 .Add 功能,请尝试使用 List 代替:

   Dim actualList As New List(Of Dictionary(Of String, String))

    Dim addRows As New Dictionary(Of String, String)
    addRows.Add("LinkTitle", "Ultimate Test Item")

    Dim addRows2 As New Dictionary(Of String, String)
    addRows2.Add("LinkTitle2", "Ultimate Test Item2")

    actualList.Add(addRows)
    actualList.Add(addRows2)

进一步阅读:IEnumerable 和 Array、IList 和 List 有什么区别?

于 2012-12-03T17:21:55.530 回答