1
在我開發我創建多個對象,每個具有以下屬性的應用程序:在這個用例中,String.Intern()的用法有什麼意義嗎?
/// <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);
}
}
的對象用於遍歷列表視圖。創建的對象可以在1到3000之間變化,這意味着從上述屬性創建的字符串對於不同的對象可以是相同的。
我的問題是:
會像String.Intern(String.Format("{0} jump{1}", Jumps, Jumps != 1 ? "s" : String.Empty))
使用中的String.intern()在這種情況下被告知。它會對創建的字符串使用的內存有任何影響嗎?
這是多久召喚一次? 「跳躍」內有多少變化? – Oded 2012-04-12 15:31:45
用每個對象調用它。跳轉值可以從-1到short.MaxValue()。 – Jimi 2012-04-12 15:34:32