المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Expanding String Abbreviations To Full String ( NASDAQ:INTC --> Intel Corporation)



C# Programming
07-01-2009, 05:21 PM
Does anyone know the best way to store and access thousands of abbreviations which are stored in a db and output the full string. For example Intel's stock symbol is INTC. When i read INTC from the db i want to set string str to Intel Corporation so the full name can be displayed to the user. currently the full string is not stored anywhere, just output on the fly based on the abbreviation and a million if-else statements http://www.barakasoft.com/script/Forums/Images/smiley_OMG.gif
ie.
if(abrev.equals("INTC")) str = "Intel Corporation";
else if(abrev.equals("GOOG")) str = "Google Inc";
....
....

Obviously the wrong way to go about it. Should the full name just be added to the db? could create hash table with abbreviation as key and full string as value. Yes the if-else method works but is awful to look at and hilariously bad. Thanks guys and gals