lunes, 11 de mayo de 2015

CODIGO CLASE NO.4 (Program.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Clase04
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.Write("Ingrese parametro 1: ");
            //int p1 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine();
            //Console.Write("Ingrese parametro 2: ");
            //int p2 = Convert.ToInt32(Console.ReadLine());

            //bool resultado = PostNeg(p1, p2, true);
            //Console.WriteLine();
            //Console.WriteLine("El resultado es: " + resultado.ToString());

           

            Estudiante estudiante = new Estudiante();
            estudiante.Nombre = "Guaroa";
            estudiante.Apellido = "Mendez";
            estudiante.Matricula = "0343";
            estudiante.NumeroCedula = "08000129178";
            estudiante.NumeroTelefono = 8096778989;
            estudiante.Edad = 15;

            Estudiante estudiante2 = new Estudiante();
            estudiante2.Nombre = "Jose";
            estudiante2.Apellido = "Nunez";
            estudiante2.Matricula = "2223";
            estudiante2.NumeroCedula = "343129138";
            estudiante2.NumeroTelefono = 82969983333;
            estudiante2.Edad = 22;

            Console.WriteLine(estudiante.Nombre);
            Console.WriteLine(estudiante2.Nombre);
           
            //ALGUNOS TIPOS DE DATOS
            /*int (entero)
             *string (cadena de caracteres)
             *char (caracter)
             *long (entero largo)
             *decimal (decimal eje 232.25)
             *bool (booleano true o false)
             *DateTime (fecha)
             *double (decimal largo)
             *float (decimal largo)
             *
             * */

            //CONVERSIONES
            //de string a int
            string edad = "32";
            int edad2 = Convert.ToInt32(edad);

            //de int a string
            int edad3 = 22;
            string edad4 = Convert.ToString(edad3);

            //de decimal a string
            decimal d1 = 145.66m;
            string numeroDecimal = Convert.ToString(d1);

            // de string a decimal
            string montoAPagar = "8949.50";
            decimal decMontoAPagar = Convert.ToDecimal(montoAPagar);

            decimal decMonto = Convert.ToDecimal("230.1");
            decimal edadx = Convert.ToInt32(40);

            bool esRojo = Convert.ToBoolean("True");

            decimal x = 20.50m;
            int numero = (int)x;

            int? cantidadCarros = null;
            decimal? montox = null;

            string apellido = "";
            string apellido2 = null;
            string a = String.Empty;
            string b = "";

            if (apellido == "")
            {
                //
            }
            if (apellido2 == null)
            {
               
            }

            Estudiante edificioNacoEstudiante = new Estudiante();
            edificioNacoEstudiante.NumeroCedula = "3434343434";

            Estudiante edificioPiantiniEstudiante = new Estudiante();

            int numeroA = 9;
            int numeroB = 8;

            int y = 9 * (9 + 1) / 4 - 2 + 1 + 2;

            switch (y)
            {
                case 9 :
                    //Realizar operacion si es 9
                    break;
                case 10:
                    //Realizar operacion si es 10
                    break;
                case 99:
                    //Realizar operacion si es 99
                    break;
                case 1:
                    //Realizar operacion si es 1
                    break;
                default:
                    break;
            }

            Console.ReadKey();

         
                 
        }

        static bool PostNeg(int num1, int num2, bool neg)
        {
            bool retorno = false;
           
            if ((num1 < 0 && num2 >0) || (num1 >0 && num2 <0))
            {
                retorno = true;
            }

            if (num1 < 0 && num2 < 0 && neg == true)
            {
                retorno = true;
            }


            return retorno;
        }
    }
}

No hay comentarios:

Publicar un comentario