c# - How to find all combinations of an List in sets of two? -


i've tried looking , didn't find i'm trying accomplish.

lets have list<int> has around 50 numbers

list<int> _mylist = new list<int>(); (int = 0; < 49; i++) {     _mylist.add(i); } 

how list of combinations based on array two?

for example result set like

  1. 1,1
  2. 1,2
  3. 1,3
  4. 1,4
  5. 1,5

and considered unique. possible 1,2 same 2,1?

i'll assume source list called input:

var output = new list<hashset<int>>(); (int = 0; < input.count; i++)     (int j = + 1; j < input.count; j++)         output.add(new hashset<int> { input[i], input[j] }); 

in case want output result console:

foreach (var result in output)     console.writeline(string.join(", ", result)); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -