In the example below... Since the class have an IDisposable interface and the class is itself is only a manage memory objects (not an unmanaged memory), so in the script further down below (See case #1 and case #2) - what is the proper way to do Disposal when done w/ the list objects?
public class VehicleA : IDisposable
{
public void Dispose() { }
public string Year {get;set;}
public string Make {get;set;}
public string Model {get;set;}
}
public class repositoryVehicle()
{
public List<VehicleA> VehicleLookup()
{
List<VehicleA> returnVehicles = new List<Vehicle>();
returnVehicles.Add(new VehicleA { Year="2007", Make="Ford", Model="Mustang" });
returnVehicles.Add(new VehicleA { Year="2004", Make="Chevy", Model="Blazer" });
return returnVehicles;
}
}
//Case #1...
foreach(var v in repositoryVehicle.VehicleLookup())
{
//v.Year...
}
//Case #2...
List<VehicleA> vehicles = new List<VehicleA>();
vehicles = repositoryVehicle.VehicleLookup();
//vehicles[x].Year...