private void btnCalc_Click(object sender, EventArgs e)
        {
            CalcPlus  DoPlus  = (a, b) => a + b; // 익명 메소드를 람다식으로 구현
            CalcMinus DoMinus = (a, b) =>
            {
                return(a - b);
            };
            CalcMul  DoMul   = (a, b) => a * b;
            CalcPlus CalcDiv = (a, b) => a / b;

            Console.WriteLine(comboBoxCalc.SelectedItem);
            switch (comboBoxCalc.SelectedIndex)
            {
            case 0:
                Console.WriteLine("Plus");
                string result = DoPlus(Int32.Parse(txtFirstNum.Value.ToString()), Int32.Parse(txtSecondNum.Value.ToString())).ToString();
                txtResult.Text = result;
                Console.WriteLine("Result : " + result);
                break;

            case 1:
                txtResult.Text = DoMinus(Int32.Parse(txtFirstNum.Value.ToString()), Int32.Parse(txtSecondNum.Value.ToString())).ToString();
                break;

            case 2:
                txtResult.Text = DoMul(Int32.Parse(txtFirstNum.Value.ToString()), Int32.Parse(txtSecondNum.Value.ToString())).ToString();
                break;

            case 3:
                txtResult.Text = CalcDiv(Int32.Parse(txtFirstNum.Value.ToString()), Int32.Parse(txtSecondNum.Value.ToString())).ToString();
                break;
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            //classes da biblioteca externa
            //Biblioteca Lib

            //Calc c = new Calc();    //não se pode instanciar uma classe abstracta
            CalcPlus  x = new CalcPlus();
            OutraCalc y = new OutraCalc();

            y.Soma(2, 3);
            x.Show("Uso de Bibliotecas:\n");

            Console.WriteLine("Soma: " + x.Soma(2, 3).ToString());

            //biblioteca HerancaLib

            Person     p = new Person();
            Medico     m = new Medico();
            Enfermeiro e = new Enfermeiro(12, "Manuel", "Geriatria");

            Console.WriteLine("Nome: " + e.nome);


            //-----

            User        u   = new User();
            Pessoa      pes = new Pessoa();
            OutraPessoa c   = new OutraPessoa();
            bool        aux = u.Login(pes);

            aux = u.Login(c);

            //----

            ZZZ aux1 = new ZZZ();

            OutraII  xx  = new OutraII();
            OutraIII xxx = new OutraIII();


            aux1.F(xx, 23, 45);
            aux1.F(xxx, 23, 45);

            Console.ReadKey();
        }