Professional Documents
Culture Documents
Capítulo 04
Arrays y Colecciones
• Control de flujo
– Branching no-condicional
– Branching condicional
– Bucles
• Excepciones
• Ver diapositivas previas.
Referencias
• Tipos de Arrays:
• Estructura de un array
• Posicionamiento en memoria
int[] pins = { 9, 3, 7, 2 };
foreach (int pin in pins)
{
Console.WriteLine(pin);
}
Desarrollo de aplicaciones .NET
Eduardo Rivera Alva - MCTS.Net (eriveraa@gmail.com)
Colecciones
Referencias
• ArrayList:
– Es la más parecida a un Array, y es una versión
más sofisticada.
– Es totalmente dinámica al manejar su contenido.
– Tiene mejor performance para el
redimensionado.
– Se le pueden agregar o remover elementos,
invocando a sus métodos.
– Es la versión no-genérica de List<T>.
• ArrayList:
{
static void Main( )
{
public class Employee List<Employee> empList = new List<Employee>( );
{ List<int> intList = new List<int>( );
private int empID;
// populate the List
public Employee( int empID ) for ( int i = 0; i < 5; i++ )
{ {
this.empID = empID; empList.Add( new Employee( i + 100 ) );
} intList.Add( i * 5 );
public override string ToString( ) }
{
return empID.ToString( ); // print all the contents
} for ( int i = 0; i < intList.Count; i++ )
public int EmpID {
{ Console.Write( "{0} ", intList[i].ToString( ) );
get }
{
return empID; Console.WriteLine( "\n" );
}
set // print all the contents of the Employee List
{ for ( int i = 0; i < empList.Count; i++ )
empID = value; {
} Console.Write( "{0} ", empList[i].ToString( ) );
} }
}
Console.WriteLine( "\n" );
Console.WriteLine( "empList.Capacity: {0}", empList.Capacity );
}
Desarrollo de aplicaciones .NET
}
Eduardo Rivera Alva - MCTS.Net (eriveraa@gmail.com)
Que veremos la próxima sesión?
• ADO.Net 2.0