1

I have a class which inherit a dictionary.

class SymbolsWithQuotes: Dictionary<string, IList<Quotes>> // ex: key: AAPL value: quotations for the last year { // Empty class } 

At first, I think its a good idea to inherit a dictionary for readability but now I have a Linq query where I end the statement by:

ToDictionary(x => x.Key, y => y.Value.ArrayObjects() .Select(blabla)); 

And I have no idea how to cast it to my class SymbolsWithQuotes.

So three questions:

1 / Was is it a good idea to inherit a dictionary for readability ?

2 / Is there a solution to cast my linq query to my object SymbolsWithQuotes

3 / Do you see an alternative solution easier to read and to maintain ? Or should I just use Dictionary> everywhere instead of object SymbolsWithQuotes

Thanks

[Edit] I precise that my linq Query does returns a type

Dictionary<string, IList<Quotes>> 

1 Answer 1

1

If your SymbolsWithQuotes is nothing but an empty class, then I suggest you not use it. As you've seen, it makes things a bit difficult.

If you just want to create an alias for the name, you could use the using directive:

using SymbolsWithQuotes = Dictionary<string, IList<Quotes>>; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.