Class or Dictionary
- by user2038134
I want to create a immutable Scale class in C#.
public sealed class Scale
{
string _Name;
string _Description;
SomeOrderedCollection _ScaleValueDefinitions;
Unit _Unit
// properties
....
// methods
ContainsValue(double value)
....
// constructors
// all parameters except scalevaluedefinitions are optional
// for a Scale to be useful atleast 1 ScaleValueDefinition should exist
public Scale(string name, string description, SomeOrderedCollection scaleValueDefinitions, unit)
{ /* initialize */}
}
so first a ScaleValueDefinition should be represented by to values:
Value (double)
Definition (string)
these values are known before the Scale class is created and should be unique.
so what is the best approach.
create a immutable class ScaleValueDefinition with value and definition as properties and use it in a list.
use a dictionary.
use another way i didn't think of...
and how to implement it.
for option 1. i can use params ScaleValueDefinition[] ValueDefinitions in the constructor, but how to do it for the other options?
and as last at what amount of value's (properties) should i choose one option over the other?