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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -