Let me use medical doctors to explain my question. Now doctors have different fields of specialization, like Neurologist=0,Oncologist=1,Cardiologist=2,Gynecologist=3 etc. Let's say I have a method that takes one of these specialities as an integer and uses it as a parameter to a stored procedure in a database:
DisplaySkills(int speciality)
{
//create a connection to a database, refer to a stored procedure in the database;
//send "speciality" as an argument to that stored procedure
}
Now, here I'm sort of in a dilemma as to whether I should have those specialities inside an enum or declare them seperately. From the first sight it feels like I should go with enums because it's just the case where "one thing can be one of several" but on the other hand it turns out that if I use enums, then I'll have to cast it to get its internal value. Here's an example:
enum Speciality
{
Neurologist=0,
Oncologist=1,
Cardiologist=2,
Gynecologist=3
}
.............
Speciality spec=Speciality.Oncologist;
.............
DisplaySkills(int(spec));
I don't know, maybe having to cast an enum is a perfectly normal practice and is widely used by programmers, but I thought it would impact the performance (no matter noticeably or not)