We’re rewarding the question askers & reputations are being recalculated! Read more.
1d
awarded  Yearling
Sep
20
answered Design pattern for objects in invalid states
Sep
17
comment How to model a Struct with a limited set of values that behaves like an enum?
Ahh yes, true. Interesting. Thanks a lot!
Sep
16
comment How to model a Struct with a limited set of values that behaves like an enum?
I like how it gives you compile time check of correct value though.
Sep
16
comment How to model a Struct with a limited set of values that behaves like an enum?
Wow. Interesting approach. But it doesn’t really remove the duplication of enum/property
Sep
14
accepted How to model a Struct with a limited set of values that behaves like an enum?
Sep
14
comment How to model a Struct with a limited set of values that behaves like an enum?
Ah sounds simple enough!
Sep
14
comment How to model a Struct with a limited set of values that behaves like an enum?
Hmm sounds like that might be the best course of action. Any chance you could update your answer with a link or two to how to do code generation? Never done that before.
Sep
14
comment How to model a Struct with a limited set of values that behaves like an enum?
If I create objects using string literals, The dictionaries will need to be constructed with dict.Add(new Codon("AAT"), new AminoAcid("A"), rather than the much more succinct dict.Add(Codon.AAT, Amino.A);. Granted, this is mostly cosmetic, but much more elegant.
Sep
14
comment How to model a Struct with a limited set of values that behaves like an enum?
The main issue I see with using strings is I have lookup dictionaries, for example: Dictionary<Codon, AminoAcid>. if I have them as strings entries of such dictionaries will be key: new Codon("AAT") , and value: new AminoAcid("A")
Sep
14
revised How to model a Struct with a limited set of values that behaves like an enum?
More applicable title
Sep
14
asked How to model a Struct with a limited set of values that behaves like an enum?
Aug
29
comment Is there a better way to use C# dictionaries than TryGetValue?
Ok I think I got it. So the action let’s you put a method in as the parameter for DoIt(). And calls that method.
Aug
29
comment Is there a better way to use C# dictionaries than TryGetValue?
Thanks. Do you think you could go into a bit more explanation of what the action method is actually doing? I’m new to actions.
Aug
28
awarded  Notable Question
Aug
28
revised Is there a better way to use C# dictionaries than TryGetValue?
added 1 character in body
Aug
28
awarded  Nice Question
Aug
28
awarded  Popular Question
Aug
27
comment Is there a better way to use C# dictionaries than TryGetValue?
I like the 2nd option. Maybe I'll have to write an extension method or two :)
Aug
27
accepted Is there a better way to use C# dictionaries than TryGetValue?