c# - Add and retrieve Key Value pair from table -
i have (read only) table containing config info, example:
red - 1, green - 2, orange - 3.
what easiest way load collection, can write, example:
byte x = mycoll.red;
one option use enum
the enum keyword used declare enumeration, distinct type consists of set of named constants called enumerator list.
the problem needs hard coded @ compile time, reading table not make sense.
the other option tio use dictionary class
represents collection of keys , values.
where @
dictionary<string, byte>
so use such
byte x = mycolldictionary["red"];
Comments
Post a Comment