Thanks Joel + Peter + Samuel for your fast responses - very helpful.
Thinking about it, I will have to use a table since I will want the end user of the database to be
able to add keywords to the database, effectively adding more "enums". I guess to improve
efficiency, I could read all of the table in my C# programme so that I don't have to make database
query everytime I want to find a corresponding number for a keyword. Does that make sense? I'm a
beginner to database and C# programming, so this might sound a bit basic.
Jay
"Jay" <-> wrote in message In C# I can set up an Enum so that number are represented as keywords, which is very useful.
Is there such a datatype in a database?
I suppose I could use an extra table, with the ID column as the number, and a corresponding column
with strings representing the keywords. This sounds a bit inefficient - is there a better way?
Jay,
Yes it does make sense. In fact you can load the values into a Dictionary
object and use the int as the key for the lookup value or the other way around.
using System;
using System.Collections.Generic;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
// using an int key and string value
Dictionary<int, string> testDict = new Dictionary<int, string>();
testDict.Add(10, "DescriptionOfEnum");
// get the string value using the int key
string str = string.Empty;
bool exists = testDict.TryGetValue(10, out str);
// or
// using a string key and int value
Dictionary<string, int> testDict2 = new Dictionary<string, int>();
testDict2.Add("DescriptionOfEnum", 10);
// get the int value using a string key
int i = 0;
exists = testDict2.TryGetValue("DescriptionOfEnum", out i);
}
}
}
Good luck with your project,
Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com