コード例 #1
0
        public static void Swap(this Dancer first, Dancer second)
        {
            var temp = first.Position;

            first.Position  = second.Position;
            second.Position = temp;
        }
コード例 #2
0
        public void Dance()
        {
            var dancersFound = new Dancer[2];

            foreach (var dancer in Lineup.Dancers)
            {
                if (dancer.Position == Position1)
                {
                    dancersFound[0] = dancer;
                    if (dancersFound[1] != null)
                    {
                        break;
                    }
                }
                else if (dancer.Position == Position2)
                {
                    dancersFound[1] = dancer;
                    if (dancersFound[0] != null)
                    {
                        break;
                    }
                }
            }
            dancersFound[0].Swap(dancersFound[1]);
        }