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

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -