I'm trying to bring a legacy C# .NET 1.1 application into the modern era. We use DataTables for our collections of what could have been business objects.
Given that most of the code thinks it is talking to the interface of a DataRow, what generic collection would make for the least painful transition?
if im reading your question rightly, you are asking for which container will just store a list of your Business objects and then allow you to just enumerate through the collection, or select via an index.
well I would consider looking into the List<>
where you methods would accept either IList<> (to access the index) or IEnumerable<> (to use a foreach loop on the collection)
for example
private void PrintAll<T>(IEnumerable<T> items)
{
foreach(T item in items)
Console.WriteLine(item.ToString());
}
now i can pass in any container which uses the IEnumerable<> interface, including List<> and the normal array
example
List<Person> people = new List<Person>();
//add some people to the list
PrintAll<Person>(people);
a sample n-tier app with Buiness objects
HTH
bones
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With