In this post, we’ll talk a little bit about string interning. As I’ve pointed out before, strings are immutable. So, it’s fair to say that the following snippet ends up wasting memory because we should end up with two different instances that, for all practical purposes, represent the same string: var str1 = "hi"; var […]
April, 2011Archive
In the previous post I’ve said that we needed a small detour into cultures to conclude the linguistic string comparison section. In .NET, the CultureInfo type holds all the information regarding a specific culture. For example, any instance of CultureInfo will give the name or calendar of a specific culture. In .NET, each culture is […]
String comparison is one of the most common operations you’ll need to perform in your daily tasks. Besides checking for equality, you’ll also end up comparing strings whenever you need to sort them. The String type offers several methods for performing comparison operations: Equals: this instance method checks two strings for equality, according with the […]
In the latest post, we’ve seen that strings are immutable. At the time, I’ve mentioned that this brings several advantages, but there are also a couple of gotchas. For instance, concatenating strings can be an expensive operation, especially when you have lots of strings. To solve this kind of problem, we need to resort to […]