Exemple #1
0
 public static void promotion(List <employee> emps, promoteDelegate promote)
 {
     foreach (employee emp in emps)
     {
         if (promote(emp))
         {
             Console.WriteLine(emp.Name + " promoted");
         }
     }
 }
Exemple #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int num = 8;
            int cellheight, cellwidth;

            cellheight = cellwidth = (pictureBox1.Width / num) + 1;
            cells      = new Button[num, num];
            for (int row = 0; row < num; row++)
            {
                for (int col = 0; col < num; col++)
                {
                    cells[row, col] = new Button();
                    if (row == 7)
                    {
                        char c = (char)(col + 65);
                        cells[row, col].Text = c.ToString();
                    }
                    if (col == 0)
                    {
                        cells[row, col].Text += (8 - row).ToString();
                    }
                    cells[row, col].TextAlign = ContentAlignment.TopRight;
                    cells[row, col].Top       = row * cellheight;
                    cells[row, col].Left      = col * cellwidth;
                    cells[row, col].Width     = cellwidth;
                    cells[row, col].Height    = cellheight;
                    cells[row, col].FlatStyle = FlatStyle.Popup;
                    cells[row, col].Font      = new Font(cells[row, col].Font.FontFamily, 8);
                    cells[row, col].Name      = "Button_" + row.ToString() + "_" + col.ToString();

                    if ((row + col) % 2 == 1)
                    {
                        cells[row, col].BackColor = Color.Gray;
                    }
                    else
                    {
                        cells[row, col].BackColor = Color.White;
                    }
                    pictureBox1.Controls.Add(cells[row, col]);
                    cells[row, col].Click += new System.EventHandler(b_Click);
                }
            }
            c1 = new chess(pictureBox1.CreateGraphics(), pictureBox1.Width, pictureBox1.Height);
            c1.passform(this);
            updatebuttons = new updateButtonsDelegate(udb);
            updatestat    = new updategamestatDelegate(uds);
            promote       = new promoteDelegate(promo);
            promoteDelete = new promoteDelDelegate(promoBegone);
            captured      = new capturedDelegate(dc);
            delCaptured   = new capturedDelegate(clearCaptured);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //DelegateHelper DH = new DelegateHelper(printHello);
            //DH();
            List <employee> emps = new List <employee>()
            {
                new fifth.employee {
                    Id = 1, Name = "keerthana", years = 3, salary = 30000
                },
                new employee {
                    Id = 2, Name = "Raj", years = 5, salary = 20000
                },
                new employee {
                    Id = 3, Name = "sravani", years = 7, salary = 10000
                }
            };
            promoteDelegate promote = new promoteDelegate(ispromotable);

            promote += ispromotable;
            promotion(emps, promote);


            Console.Read();
        }