DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

2
kicks
submitted by hockman 4 months, 9 days ago

hockblogs.net — In a lot of projects different users use different string comparison methods. I’ve seen a lot of code where there is a lot of ToLowers(), Equals, equality == operators, string.compare, string.CompareTo, and so on used for comparing strings. All different usages, sometimes for different purposes, but 99% of the time for the same purpose. Since .NET 2.0 however, Microsoft has new recommendations, and I think it is really a must to read. A link to the new Microsoft recommendations can be found at the end of this article. There are two very important things to ask yourself when comparing string: * Should my string be treated as a symbolic set of bytes (an ordinal interpretation)? * Should my string vary over culture (a culture-sensitive interpretation)? If the string data, that is designed to be culture-agnostic and linguistically irrelevant, start using the StringComparison overloads, using either the StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase. These two overloads enforce a byte-by-byte comparison similar to strcmp that not only avoids bugs from linguistic interpretation of essentially symbolic strings, but provides better performance!

Add a comment add a comment | category: | Views: 6 | Get KickIt image code
tags: | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:

No comments so far




information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge