I am developing a web project with .net. In this project the city names will be selected in a combo box. That's why I'm considering keeping the city names as enums. Is there any easier and more practical way to do this?
CodePudding user response:
You have to think ahead whether City is used in any part of the logic inside your app. Using City as enum will cause problem later when you want to remove a city, and the integer number representing the enum maybe reused for other city?
For example you have a city enum consist of New York, San Francisco and Seattle. When you store them in database, you either store it as number of 0,1,2 or as the string name of the city.
Down the road you may want to remove the Seattle, then you will need to patch the data table or update the code so that when you read Seattle from database, you needto map the enum properly or make it null.