Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi ,

I'm trying to use a dictionary in c# as follows

Dictionary<Type,IStorage<IEntity>>
and seems to be the declaration and initialization are ok .
Then I create an instance of
C#
Orderstore:IStorage<Order>
where Orderstore implements the IStorage and Order implements IEntity.

But when I try to add Orderstore to the dictionary it says "Argument type Orderstore is not assignable to parameter type IStorage<order>"
I wonder anyone can help me with this. Thanks in advance.
Posted
Updated 15-Jan-13 22:18pm
v2
Comments
Sergey Alexandrovich Kryukov 16-Jan-13 1:07am    
I cannot believe that exception message contains the words "return of the Dictionary", as they make no sense.
It may work out if you show the minimal code sample. Show how you initialize key and value object and add a dictionary element to it.
—SA
Suvabrata Roy 16-Jan-13 4:54am    
Please share the order class and some code ...
Sergey Alexandrovich Kryukov 16-Jan-13 14:10pm    
You are right, but better reply to OP's post, not mine. Not a problem though...
—SA
Suvabrata Roy 16-Jan-13 23:26pm    
OP's Post mean ...?
Sergey Alexandrovich Kryukov 16-Jan-13 23:42pm    
Oh, sorry for this abbreviation; it's just the jargon we use on this site, which as not very good, as many don't know it. OP means "Original Poster" or "Original Publisher", something like that, in this case, prasadbuddhika.
—SA

1 solution

Use the code given below:

Dictionary<type,isynchronizedstorage><isynchronizableentity>> myOrders;

If myOrders is the name of the dictionary, then use

Orderstore<order> order = myOrders[index] as Orderstore;

TypeCast it "as OrderSto0re" then your code will work.

Regards.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900