Sum of subset of 5 numbers equals 0
Using a List&lt;int&gt; instead of int[] allows your code to not only be more dynamic but also to leverage the GetRange method of the List.  This simplifies your code to only 2 loops.

Creating the list would look something like this:

int number;
List&lt;int&gt; Numbers = new List&lt;int&gt;();
for(int i = 0; i &lt;= 4; i++)
{
    number = 0;
    bool good = false;
    while(!good)
    {
        Console.WriteLine("Input number {0}", i + 1);
        if(int.TryParse(Console.ReadLine(), out number))
        {
            Numbers.Add(number);
            good = true;
        }
        else
            Console.WriteLine("Invalid input, try again");
    }

}


The sub routine to get the subsets could look something like this:

public static List&lt;List&lt;int&gt;&gt; AllSubsets2(List&lt;int&gt; mainset, int targetsum)
{
    List&lt;List&lt;int&gt;&gt; outval = new List&lt;List&lt;int&gt;&gt;();
    for(int num2 = 0; num2 &lt; mainset.Count; num2++)
    {
        if(mainset[num2] == 0)
            outval.Add(new List&lt;int&gt;{mainset[num2]});
        int sum = mainset[num2];
        for(int num = num2+1; num &lt; mainset.Count; num++)
        {
            sum += mainset[num];
            if(sum == 0)
                outval.Add(mainset.GetRange(num2, num - num2));
        }
    }

    return outval;
}


This will return a list of all the subsets that add up to the target sum.