© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•9mo ago•
26 replies
Bird 6

✅ Finding all possibilities of N length in an array

Hey so I have the Following code which basically iterate on all my tiles and create arrays of 3 of them, iterating on all possibilities
List<Tile[]> tiles = [];
for (int i = 0; i < matching.Length - 1; i++)
{
    for (int y = i + 1; y < matching.Length - 1; y++)
    {
        tiles.Add([tile, matching[i], matching[y]]);
    }
}
return tiles;
List<Tile[]> tiles = [];
for (int i = 0; i < matching.Length - 1; i++)
{
    for (int y = i + 1; y < matching.Length - 1; y++)
    {
        tiles.Add([tile, matching[i], matching[y]]);
    }
}
return tiles;


I'm trying to make this code generic so instead of arrays of 3, it can be array of N, but I'm not sure how to approche that

Could someone please help me with that?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Best way to uniquely hash an array of undefined length?
C#CC# / help
3y ago
How do I check the length of an array when that array is null?
C#CC# / help
4y ago
❔ Possibilities in simplifying these loops?
C#CC# / help
3y ago