static void Main(string[] args)
{
string[] array ={"1","2","3","4","5"};
List<ArrayList> list1 = new List<ArrayList>();
List<ArrayList> list2 = new List<ArrayList>();
list1.Add(new ArrayList());
list1[0].Add(array[0]);
for(int count=0;count<array.Length-1;count++)
{
list2.Clear();
for (int i = 0; i < list1.Count; i++)
{
list1[i].Add(array[count + 1]);
#region
for (int j = 0; j < list1[i].Count; j++)
{
ArrayList arraylist = new ArrayList();
for (int d = 0; d < list1[i].Count; d++)
{
if (j == d)
arraylist.Add(list1[i][(list1[i].Count) - 1]);
else if (d == list1[i].Count - 1)
arraylist.Add(list1[i][j]);
else
arraylist.Add(list1[i][d]);
}
list2.Add(arraylist);
}
#endregion
}
list1.Clear();
for (int a = 0; a < list2.Count; a++)
{
ArrayList arraylist = new ArrayList();
for (int b = 0; b < list2[a].Count; b++)
{
arraylist.Add(list2[a][b]);
}
list1.Add(arraylist);
}
}
for (int a = 0; a < list2.Count; a++)
{
Console.Write((a + 1)+"\t\t");
for (int b = 0; b < list2[a].Count; b++)
{
Console.Write(list2[a][b]);
}
Console.WriteLine();
}
Console.Read();
}