0

I'm currently trying to add a dictionary(Of string, string) to an Ienumerable(Of Dictionary(Of string, string))

It seems simple enough, yet I can't find an answer...Here's my code if you need a better explination

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

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

I suppose right here, I'd attempt to put addrows into actualList, but I've had trouble doing so....

'this sends our custom dictionary to sharepoint
        Dim updateOutput = ListServiceUtility.UpdateListItems(Test_Sharepointsite_url, myCred, Test_List_Name, Nothing, addRows.AsEnumerable, 1)
KreepN
  • 8,528
  • 1
  • 40
  • 58
Lenigod
  • 153
  • 5
  • 17

1 Answers1

4

IEnumerable doesn't have the .Add functionality you are looking for, try using a List instead:

   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)

Further reading : What's the difference between IEnumerable and Array, IList and List?

Community
  • 1
  • 1
KreepN
  • 8,528
  • 1
  • 40
  • 58
  • I just wanted to give you extra props here, for using my variable names and test data in your example on how to use a list. Makes everything a lot easier to understand. – Lenigod Dec 03 '12 at 21:30
  • @Lenigod No prob, lemme know if you need any extra help by leaving me a comment here. I help a good few SO users learn new things, as it's why I enjoy posting here. – KreepN Dec 03 '12 at 22:14