0

I am working with Auth0 where i need to update appmetadata .

this is how my app meta data looks like

userUpdateRequest.AppMetadata = new Dictionary<string, dynamic>
{
 {"toysNumber",new List<int> {2,3,9,77} }
};

I have a list of int that contains some more toys number.

List<int> itemsToAddInMetadata = new list<int>{22,33,65,..}.

I want to do something like that -

userUpdateRequest.AppMetadata = new Dictionary<string, dynamic>
{
 {"toysNumber",new List<int> {2,3,9,77,itemsToAddInMetadata} }
};

I cant figure out the correct syntax. how can i insert list of int in another list like for loop ? [NB: in my case the issue was proper syntax]

user12
  • 7
  • 1
  • 3

3 Answers3

3

You can simply add the numbers via the constructor of the new List<int>

   var itemsToAddInMetadata = new List<int> { 22, 33, 65 };

   userUpdateRequest.AppMetadata = new Dictionary<string, dynamic>
   {
      { "toysNumber", new List<int>(itemsToAddInMetadata) { 2, 3, 9, 7 } }
   };
pazcal
  • 929
  • 5
  • 26
1

Add two lists first:

List<int> itemsToAddInMetadata = new List<int>{22, 33, 65};
List<int> itemsToAddInMetadata1 = new List<int> { 22, 33, 65 };
itemsToAddInMetadata1.AddRange(itemsToAddInMetadata);

Then add the whole list to your dictionary:

userUpdateRequest.AppMetadata = new Dictionary<string, dynamic>
{
 {"toysNumber",itemsToAddInMetadata1}
};
Arif Anwarul
  • 106
  • 1
  • 2
0

Try something like that:

userUpdateRequest.AppMetadata["toysNumber"].AddRange(new[] {22, 33, 65, ...})
matiii
  • 316
  • 4
  • 17