Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

concatinating int[] to same size string[]

Tags:

c#

.net

i have:

int[] numbers = { 1, 2, 3};
string[] words = { "one", "two", "three" };

and need the output to be

1=one
2=two
3=three

thanks


1 Answers

if they are the same size you can use

int[] numbers = { 1, 2, 3};
string[] words = { "one", "two", "three" };

var list = numbers.Zip (words, (n, w) => n + "=" + w);

but note if they differ in size the non match items will be ignored

like image 164
Maged Samaan Avatar answered Apr 09 '26 05:04

Maged Samaan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!