日期:2014-05-17  浏览次数:20857 次

求写一个循环.
       public static void OnlyOneSelectAndCray(CheckBox p1, CheckBox p2, CheckBox p3, CheckBox p4)
       {
           OnlyOneSelectAndCray(p1, p2);
           OnlyOneSelectAndCray(p3, p2);
           OnlyOneSelectAndCray(p3, p1);
           OnlyOneSelectAndCray(p4, p1);
           OnlyOneSelectAndCray(p4, p2);
           OnlyOneSelectAndCray(p4, p3);
       }
       public static void OnlyOneSelectAndCray(CheckBox p1, CheckBox p2, CheckBox p3, CheckBox p4, CheckBox p5)
       {
           OnlyOneSelectAndCray(p1, p2);
           OnlyOneSelectAndCray(p3, p2);
           OnlyOneSelectAndCray(p3, p1);
           OnlyOneSelectAndCray(p4, p1);
           OnlyOneSelectAndCray(p4, p2);
           OnlyOneSelectAndCray(p4, p3);
           OnlyOneSelectAndCray(p5, p1);
           OnlyOneSelectAndCray(p5, p2);
           OnlyOneSelectAndCray(p5, p3);
           OnlyOneSelectAndCray(p5, p4);
       }

每两个参数之间都执行方法OnlyOneSelectAndCray.
能写一个不限参数个数的方法吗? params CheckBox[] p1
求大神指教.

------解决方案--------------------
   public static void OnlyOneSelectAndCray(params  CheckBox[] p1)
        {
            for (int i = 0; i < p1.Length; i++)
            {
                for (int j = i + 1; j < p1.Length; j++)
                {
                    OnlyOneSelectAndCray(p1[i], p1[j]);
                }
            }
        }
     

------解决方案--------------------
public static void OnlyOneSelectAndCray(param CheckBox[] checkboxs)
{
    var list = checkboxs.SelectM