Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

SortedList with a Generic Value

$
0
0

Hi there,

I want to use the SortedList<> as aTyped lookup for some classed i have. all the classes inherit from ObjectTable<T> where T is the type of a business object.

ObjectTable<> exposes methods like Save, Archive, Delete etc.

Now my question is, can I use a generic SortedList / Dictionary to accomplish the following:

 

SortedList<string, ObjectTable<>> tableList = new SortedList<string, ObjectTable<>>();

tableList.Add("Customers", customerTable); // here customerTable is derived from ObjectTable<Customer>

and then can I access the newly inserted table's methods like this?

 

tableList["Customers"].Save(obj);

 

Thanks!

Marcel


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>