Você está na página 1de 17

Screen clipping taken: 24/04/2014 09:34 a.m.

Estamos accediendo desde otro


proyecto a una funcin de
CursoCsharpConsole2
Proyecto anidado para poder acceder a
una funcion
jueves, 24 de abril de 2014 09:34 a.m.
.Net Page 1
Screen clipping taken: 24/04/2014 09:39 a.m.
Constructor
jueves, 24 de abril de 2014 09:39 a.m.
.Net Page 2
Screen clipping taken: 24/04/2014 09:41 a.m.
jueves, 24 de abril de 2014 09:41 a.m.
.Net Page 3
Screen clipping taken: 24/04/2014 09:41 a.m.
jueves, 24 de abril de 2014 09:41 a.m.
.Net Page 4
Screen clipping taken: 24/04/2014 09:44 a.m.
.Net Page 5
Screen clipping taken: 24/04/2014 09:45 a.m.
Tamao en bytes de un doble
jueves, 24 de abril de 2014 09:45 a.m.
.Net Page 6
Screen clipping taken: 24/04/2014 09:55 a.m.
Diccionario
jueves, 24 de abril de 2014 09:55 a.m.
.Net Page 7
Screen clipping taken: 24/04/2014 09:57 a.m.
jueves, 24 de abril de 2014 09:57 a.m.
.Net Page 8
Screen clipping taken: 24/04/2014 10:08 a.m.
jueves, 24 de abril de 2014 10:08 a.m.
.Net Page 9
Molina, Jose Carlos
10:38 a.m.
Random id = new Random();
var alumnos = new alumno[5];
for (int i = 0; i < alumnos.Length; i++)
{
alumnos[i] = new alumno(id.Next(),"Alumno x",i+5);
}
foreach (alumno al in alumnos)
{
Console.WriteLine("id = {0} nombre{1}, edad{2}",al.Id,al.Nombre,al.Edad);
}
Console.ReadLine();
}
Molina, Jose Carlos
11:10 a.m.
var items = new Queue<int>();
items.Enqueue(100);
for (int item = 0; item < 50; item++)
{
items.Enqueue(item);
}
foreach (int item in items)
{
Console.Write("{0},",item);
}
var lastQueue = items.Dequeue();
Console.WriteLine("\n the dequeued item is : {0}", lastQueue);
lastQueue = items.Dequeue();
Console.WriteLine("\n the dequeued item is : {0}", lastQueue);
Console.ReadLine();
jueves, 24 de abril de 2014 10:39 a.m.
.Net Page 10
Screen clipping taken: 24/04/2014 11:17 a.m.
IF terneario
jueves, 24 de abril de 2014 11:17 a.m.
.Net Page 11
Screen clipping taken: 24/04/2014 11:29 a.m.
Estructura de un
metodo
jueves, 24 de abril de 2014 11:29 a.m.
.Net Page 12
Screen clipping taken: 24/04/2014 11:35 a.m.
Sobrecarga
Method overloading allws a class to have
multiple methods with the
same name, but with a different signature,
so functions can be overloaded
based on the number, type and kind of
parameters.
The signature of a method consit of the name of
the methond and the type,
kind(value, reference, or output), and the
number if its parameters, does not includes
the return type and the params modifier,
so is not possible to overload a function
just based on the return type or params
modifier.
jueves, 24 de abril de 2014 11:35 a.m.
.Net Page 13
Screen clipping taken: 24/04/2014 11:43 a.m.
Parametros opcionales
Restofnumbers es un arreglo que recibe todos los parametros extras que se agreguen
jueves, 24 de abril de 2014 11:43 a.m.
.Net Page 14
Screen clipping taken: 24/04/2014 11:45 a.m.
Aqu se ve como puedes agregar mas parametros
jueves, 24 de abril de 2014 11:45 a.m.
.Net Page 15
Screen clipping taken: 24/04/2014 11:47 a.m.
Escribir el using de arreiba
para poder utilizar el
optionalattribute
para crear un
parametro
opcional
jueves, 24 de abril de 2014 11:47 a.m.
.Net Page 16
Screen clipping taken: 24/04/2014 12:04 p.m.
Creacion de una excepcion
Terminar en Exception y heredar de applicationexception
Crear el constructor con el mensaje que queremos
Screen clipping taken: 24/04/2014 12:05 p.m.
Screen clipping taken: 24/04/2014 12:06 p.m.
class Program
{
static void Main(string[] args)
{
Temperature temp = new Temperature();
try
{
temp.showTemp();
}
catch (TempIsZeroException e)
{
Console.WriteLine("TempIsZeroException: {0}", e.Message);
}
Console.ReadLine();
}
}
public class Temperature
{
int temperature = 0;
public void showTemp()
{
if (temperature == 0)
{
throw (new TempIsZeroException("Zero Temperature found
alsdkjfasldkfjsdl"));
}
else
{
Console.WriteLine("Temperature: {0}", temperature);
}
}
}
public class TempIsZeroException : ApplicationException
{
public TempIsZeroException(string message) : base(message)
{
}
}
class Program
jueves, 24 de abril de 2014 12:04 p.m.
.Net Page 17

Você também pode gostar