.net - can this value be output with inline code in c#? -


please consider following inline code:

string.join(",", context.request.headers.toarray()) 

if headers structure above dictionary(string, string), code above output following:

[myheaderkey1, myheaderval1],[myheaderkey2, myheaderval2] 

however, dictionary value string[] following gets output instead:

[myheaderkey1, system.string[]],[myheaderkey2, system.string[]] 

i need able generate output first code example against dictionary string[] value. it's ok if take first item of dictionary - string[] value. can done inline c#?

yes. use linq select.

string.join(",", context.request.headers.select(x => string.format("[{0}, {1}]", x.key, formatthisarray(x.value)))) 

edit: since op mentioned value string[], default x.value described above may not produced desired output. i'm not sure how op format value of dictionary item , assuming formatthisarray function formats array.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -