A
Anonieko Ramos
The logical thing to do is to try it yourself.
See this example:
-----------------------------------------------------------
using System;
using System.Collections.Generic;
namespace Tests
{
public class Employee
{
int id;
string name;
public Employee(int anId, string aName)
{
this.id = anId;
this.name = aName;
}
public int Id
{
get { return this.id; }
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
}
}
namespace Tests
{
public class GenericReferenceArrayListTest {
static void Main()
{
DateTime start = DateTime.Now;
List<Employee> employees = new List<Employee>();
Employee emp = new Employee(101, "Smith, Joan");
for (int i = 0; i < 1000000; i++)
{
employees.Add(emp);
}
foreach (Employee e in employees)
{
Employee currentEmployee = e;
}
DateTime finish = DateTime.Now;
System.Console.WriteLine(String.Format("Elapsed time: {0}",
finish.Subtract(start)));
}
}
}
See this example:
-----------------------------------------------------------
using System;
using System.Collections.Generic;
namespace Tests
{
public class Employee
{
int id;
string name;
public Employee(int anId, string aName)
{
this.id = anId;
this.name = aName;
}
public int Id
{
get { return this.id; }
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
}
}
namespace Tests
{
public class GenericReferenceArrayListTest {
static void Main()
{
DateTime start = DateTime.Now;
List<Employee> employees = new List<Employee>();
Employee emp = new Employee(101, "Smith, Joan");
for (int i = 0; i < 1000000; i++)
{
employees.Add(emp);
}
foreach (Employee e in employees)
{
Employee currentEmployee = e;
}
DateTime finish = DateTime.Now;
System.Console.WriteLine(String.Format("Elapsed time: {0}",
finish.Subtract(start)));
}
}
}