C
C#3y ago
Ted Bunny

Abstract List of KeyValuePairs

public abstract List<KeyValuePair<string, int>> inventory;
public abstract List<KeyValuePair<string, int>> inventory;
It says I can't do this with a field, and to try a property instead. Doing that doesn't resolve it. I've never received this message when declaring an abstract variable. Any suggestions?
8 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ted Bunny
Ted BunnyOP3y ago
Ah ok, I forgot the {get;} Adding that does what I needed. Thanks!
jcotton42
jcotton423y ago
abstract is "this member needs to be implemented by deriving classes" Fields don't have implementations, they just exist Also, why a List of KVP instead of a dictionary?
Ted Bunny
Ted BunnyOP3y ago
I need non-unique keys
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ted Bunny
Ted BunnyOP3y ago
I used the auto-suggested version, I forget what it looked like Is there a better structure than List<KVP>? I've never used it before
senox13
senox133y ago
Depending on the performance requirements of this code, I'd be inclined to suggest just implementing your own MultiDictionary type. Sounds like it'd make for a cleaner end product
Ted Bunny
Ted BunnyOP3y ago
Yeah, I'm really not liking the clunky syntax of the KVP stuff. I'll give that a shot. Thanks, all!
Want results from more Discord servers?
Add your server