Click here to Skip to main content
12,455,917 members (88,820 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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
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"
I wonder anyone can help me with this. Thanks in advance.
Posted 15-Jan-13 18:23pm
Updated 15-Jan-13 22:18pm
v2
Comments
   
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
Suvabrata Roy 16-Jan-13 23:47pm
   
Ok, I understand :)

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use the code given below:

Dictionary<type,isynchronizedstorage>> myOrders;

If myOrders is the name of the dictionary, then use

Orderstore order = myOrders[index] as Orderstore;

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

Regards.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100