コード例 #1
0
        static void Main(string[] args)
        {
            Euro ahorroEuro = new Euro(5);

            Dolar cantEnDolares = new Dolar(0);
            Pesos cantEnPesos   = new Pesos(0);


            cantEnDolares = (Dolar)ahorroEuro;
            cantEnPesos   = (Pesos)ahorroEuro;


            Console.WriteLine("En dolares: {0}", cantEnDolares.GetCantidad());
            Console.WriteLine("En pesos: {0}", cantEnPesos.GetCantidad());

            Console.ReadKey();
        }
コード例 #2
0
        private void btnConverPesos_Click(object sender, EventArgs e)
        {
            double numero      = 0;
            Euro   monedaEuro  = new Euro(0);
            Dolar  monedaDolar = new Dolar(0);
            Pesos  monedaPesos = new Pesos(0);

            if (double.TryParse(textDolar.Text, out numero))
            {
                monedaPesos = numero;

                monedaEuro         = (Euro)monedaPesos;
                txtPesosAEuro.Text = monedaEuro.GetCantidad().ToString();

                monedaDolar         = (Dolar)monedaPesos;
                txtPesosADolar.Text = monedaDolar.GetCantidad().ToString();

                txtPesosAPesos.Text = numero.ToString();
            }
        }