c# - Best way to enumerate all combinations -


suppose have following list in order:

s1  r1  r2  s2 s3 

i need create list each "s" contains each "r" combination

output:

s1 => r1 s1 => r2 s2 => r1 s2 => r2 s3 => r1 s3 => r2 

what's best way achieve this? thanks

try:

var byprefix = list.groupby(i => i.first()).todictionary(g => g.key, g => g); var result =      s in byprefix['s']     r in byprefix['r']     select new { s, r }; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -