Reputation: 1228
In the app I'm developing I'm creating several objects that each have the following property:
/// <summary>
/// Gets the jumps text.
/// </summary>
public string JumpsText
{
get
{
return Jumps == -1 ? String.Empty : String.Format("{0} jump{1}", Jumps, Jumps != 1 ? "s" : String.Empty);
}
}
The objects are used to iterate a listview. Objects created can vary from 1 to up to 3000 which means that the string created from the above property can be the same for different objects.
My question is:
Would the use of String.Intern() like String.Intern(String.Format("{0} jump{1}", Jumps, Jumps != 1 ? "s" : String.Empty))
be advised in this case. Will it have any impact on the memory used by the created strings?
Upvotes: 1
Views: 100
Reputation: 13545
For a few thousand entries it does not matter at all. As a rule of the thumb as long as the Listview is not virtual due to performance and memory consumption reasons you do not need to worry about string interning.
Upvotes: 1