Working with an API where I need to send a value over in an array of NVPairs, like the following:
new[]
{
new[]
{
new NVPair
{
name = "email_address",
value = "email1@email.com"
}
},
new[]
{
new NVPair
{
name = "email_address",
value = "email2@email.com"
}
}
}
I need to be able to create this (the value, or “email2@email.com”) from a list of strings (that will be the email addresses).
Would anyone be able to provide some guidance?
Assuming you really want an array of single-element arrays, I suspect you want:
This is also assuming that the
NVPairtype in question has a two-parameter constructor, taking the name and the value. If it doesn’t, the query becomes uglier:Note the
new[]so that each element is transformed into a single-element array.Another option which would at least work from a compile-time point of view is to create a single-element outer array, where its sole element was a multi-element array: