|
|
Choosing A Webhost: |
Re: Best way to convert "cAsE" to "Case"?: msg#00150windows.devel.dotnet.cx
actually i did do the Upper solution. The reason i WAS using a mixed case was solely for my readability and code cleanliness. I prefer the look vs ALL CAPS / lower, But none the less, i gave in until i find another solution. But im not ganna waste all my time on this little thing :o So for now all the enums are CAPS, and i use ToUpper() On 9/20/05, Kenneth Lee <KPLCJL@xxxxxxx> wrote: > In a message dated 9/19/2005 6:07:53 PM Pacific Standard Time, > zeusbwr@xxxxxxxxx writes: > > perfect! though i still need to get by IsDefined.. > > > > > So, why are you writing YOUR enum in mixed case? (If someone else is > writing it, getting around case could get tricky ->"ThisValueIsMine". > "THISVALUEISMINE" is easy to match.) > > You could have a set of if statements: > if (InpStr.ToLower() == "thisvalueismine") InpStr = "ThisValueIsMine" ; > and use whatever case enum values you want. You could wrap the set with an > if !IsDefined so the logic is only executed when case doesn't already match. > (NOT my favorite solution, change the set of enums, change this logic.) > > You could loop through the enum values and convert both the values and the > input string to lower case and compare them. (A better solution.) > > You can use the try/catch method. If you've already converted the value to > a string, verified it isn't null, then set up the try/catch to only convert > the string to an enum, you've pretty much eliminated the possible alternate > errors. (If the other program blows up, it will never reach the try, the > catch > won't be executed.) Let the purists on this board howl, it's a solution. > > I'd still like an answer to my first question. That removes the problem > completely and it should keep any purist reading your code happy. > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > -- Zeusbwr[at]gmail.com, http://www.google.com/talk/ Project Blog: http://zeusbwr.blogspot.com/ =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Best way to convert "cAsE" to "Case"?, Kenneth Lee |
|---|---|
| Next by Date: | Re: ArrayList stored in DataSet? (What can & Cant be stored?), Kenneth Lee |
| Previous by Thread: | Re: Best way to convert "cAsE" to "Case"?, Kenneth Lee |
| Next by Thread: | ArrayList stored in DataSet? (What can & Cant be stored?), Zeusbwr |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |