A btter way to represent Same value given multiple values(C#3.0)
Posted
by Newbie
on Stack Overflow
See other posts from Stack Overflow
or by Newbie
Published on 2010-04-29T02:42:06Z
Indexed on
2010/04/29
2:47 UTC
Read the original article
Hit count: 224
I have a situation for which I am looking for a more elegant solution.
Consider the below cases
"BKP","bkp","book-to-price" (will represent) BOOK-TO-PRICE
"aop","aspect oriented program" (will represent) ASPECT-ORIENTED-PROGRAM
i.e. if the user enter BKP or bkp or book-to-price , the program should treat that as BOOK-TO-PRICE. The same holds good for the second example(ASPECT-ORIENTED-PROGRAM).
I have the below solution:
Solution:
if (str == "BKP" || str == "bkp" || str == "book-to-price" ) return "BOOK-TO-PRICE".
But I think that there can be many other better solutions .
Could you people please give some suggestion.(with an example will be better)
I am using C#3.0 and dotnet framework 3.5
© Stack Overflow or respective owner