tag:blogger.com,1999:blog-5280710301280348838.post6900737510285952157..comments2023-09-05T06:19:29.538-07:00Comments on Developers 42: Adventures while building a Silverlight Enterprise application part #9Jonathan van de Veenhttp://www.blogger.com/profile/15269789903353187250noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-5280710301280348838.post-6866438790763970762010-01-06T11:26:50.260-08:002010-01-06T11:26:50.260-08:00When you need to get things done, sometimes a hamm...When you need to get things done, sometimes a hammer is still the best tool.Shawn Shepardhttps://www.blogger.com/profile/18227913410688191938noreply@blogger.comtag:blogger.com,1999:blog-5280710301280348838.post-73620439699387592882009-07-22T23:25:46.880-07:002009-07-22T23:25:46.880-07:00You're welcome, off the back. It's always ...You're welcome, off the back. It's always good to know you've helped someone with a good blog post.Jonathan van de Veenhttps://www.blogger.com/profile/15269789903353187250noreply@blogger.comtag:blogger.com,1999:blog-5280710301280348838.post-60226829950465196062009-07-22T11:42:00.701-07:002009-07-22T11:42:00.701-07:00The method you describe worked terrific for me. I ...The method you describe worked terrific for me. I had been struggling with getting the SelectedItem property to work on my Silverlight ComboBoxes. Thanks so much for this post!Off The Backhttps://www.blogger.com/profile/06290855627590183549noreply@blogger.comtag:blogger.com,1999:blog-5280710301280348838.post-36629732618825248402009-04-02T04:29:00.000-07:002009-04-02T04:29:00.000-07:00Hi vlad,You're absolutely right, they are inconsis...Hi vlad,<BR/><BR/>You're absolutely right, they are inconsistent. My example application is not the ideal scenario, as I would not want this to be based on strings anyway. As discussed earlier, you would want to use a unique identifier to compare on.<BR/><BR/>But I get your point. Always use consistent logic in Equals and GetHashCode.<BR/><BR/>Greets,<BR/>JonathanJonathan van de Veenhttps://www.blogger.com/profile/15269789903353187250noreply@blogger.comtag:blogger.com,1999:blog-5280710301280348838.post-34503546934799751602009-04-02T04:02:00.000-07:002009-04-02T04:02:00.000-07:00jonathan, You're using an OrdinalIgnoreCase compar...jonathan, <BR/><BR/>You're using an OrdinalIgnoreCase comparison in your Equals method, while simply returning the string's normal hash code in GetHashCode so the two methods are not consistent with each other.<BR/><BR/>For instance, Equals will return true for "LaptoP" and "laPTop" but GetHashCode will return different values for them.Vladhttps://www.blogger.com/profile/04844785204434053898noreply@blogger.comtag:blogger.com,1999:blog-5280710301280348838.post-72789410841084204282009-03-18T05:07:00.000-07:002009-03-18T05:07:00.000-07:00Hi SteveG,Good question, thanks.Yes, using an id t...Hi SteveG,<BR/><BR/>Good question, thanks.<BR/>Yes, using an id to compare objects is completely valid. The goal is to make sure that equal objects in diferent instances still evaluate as being equal. <BR/><BR/>This is not default behaviour because objects normally are compared based on where the pointer for that object points in memory (different instances mean different objects).<BR/><BR/>Another aproach could be to have more then one property that makes for a unique object. In that case, having an equals method to first combine these properties before a compare can be a valid solution, but that realy depends on specifics for the application. Having an id is always the safest way to go.<BR/><BR/>Does that answer your question?<BR/><BR/>Greets,<BR/>JonathanJonathan van de Veenhttps://www.blogger.com/profile/15269789903353187250noreply@blogger.comtag:blogger.com,1999:blog-5280710301280348838.post-91716621786971969052009-03-18T04:31:00.000-07:002009-03-18T04:31:00.000-07:00Thank you.Question: I'm using a template to displa...Thank you.<BR/><BR/>Question: I'm using a template to display the 'displaymember' that uses a converter <BR/><BR/>ie.<BR/><BR/>Laptop Model 123<BR/><BR/>The converter taking 2 fields and combining them.<BR/><BR/>What would I use for my Equals? Any unique item of Casing? (ie. a Casing Id)Anonymoushttps://www.blogger.com/profile/01825849412942634456noreply@blogger.com