Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            IntegerToInteger ii = new IntegerToInteger(Caculator.Add);

            ii += Caculator.Subtract;
            ii += new Caculator().Division;
            ii(2, 5);


            TaxMoney tm  = TaxCaic.GetTax("US");// tm la 1  delegate
            float    tax = tm(100000000);

            Console.WriteLine("thue phai nop " + tax);


            //tao 1 ham an danh bang delegate
            TaxMoney tm2 = delegate(float salary)
            {
                return(salary * 40 / 100);
            };
            float frTax = tm2(10000);

            Console.WriteLine("thue tai phap " + frTax);



            PhepTinh pt = Pheptinh.GetPt("-");
            int      c  = pt(2, 3);

            Console.WriteLine("ket qua " + c);
        }
        //private int i = 0, j = 0;


        public MainPhepTinh()
        {
            InitializeComponent();
            phepTinh = AddList();
            //if (j == 1)
            //    Next();
        }
Exemplo n.º 3
0
        protected void buttonMR1_Click(object sender, EventArgs e)
        {
            PhepTinh p  = (a, b) => a - b;
            int      kq = p(7, 5);

            labelKetQua.Text = kq.ToString();
        }
        private PhepTinh AddList()
        {
            PhepTinh phepTinh = new PhepTinh();

            phepTinh.DeBai   = "Em hãy tự tạo ra một bài toán có phép tính sau: 10 + 7. Sau đó giải bài toán đó.";
            phepTinh.BaiToan = @"";
            phepTinh.LoiGiai = @"";
            phepTinh.Check   = true;
            return(phepTinh);
        }
Exemplo n.º 5
0
        protected void buttonTich_Click(object sender, EventArgs e)
        {
            // Khai báo biến p kiểu delegate PhepTinh
            PhepTinh p;

            // Khởi tạo p tham chiếu đến phương thức TinhTich
            p = new PhepTinh(TinhTich);
            // Gọi delegate p thực thi
            int kqTich1 = p.Invoke(2, 5);
            int kqTich2 = p(3, 4);
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            EditTuRaDe editTuRaDe = new EditTuRaDe(phepTinh);
            bool?      result     = editTuRaDe.ShowDialog();

            if (result == true)
            {
                //phepTinh = editTuRaDe.GetPhepTinh();
                phepTinh = editTuRaDe.GetPhepTinh();
                //i += 1;
                SetData();
            }
        }
Exemplo n.º 7
0
        protected void buttonMR2_Click(object sender, EventArgs e)
        {
            PhepTinh tinhTienBanHang = (soLuong, donGia) =>
            {
                int kq = soLuong * donGia;
                if (kq >= 1000000)
                {
                    kq -= 100000;
                }
                return(kq);
            };
            int soTien = tinhTienBanHang(10, 100000);

            labelKetQua.Text = soTien.ToString();
        }
Exemplo n.º 8
0
        protected void btnTinh_Click(object sender, EventArgs e)
        {
            PhepTinh pt;

            if (rbTong.Checked == true)
            {
                pt = new PhepTinh(Tong);// khởi tạo biến pt kiểu delegate PhepTinh tham chiếu đến phương thức tổng
            }
            else
            {
                pt = new PhepTinh(Tich);// khởi tạo biến pt kiểu delegate PhepTinh tham chiếu đến phương thức tích
            }
            //int kq = pt.Invoke(2, 5);
            int kq2 = pt(2, 5);// gọi phương thức thực thi

            lbKetQua.Text = "Kết Quả" + kq2;
        }