.Net フレームワーク固有の文字列インターンのプロセスと内部構造を知りたいです。また、インターニングを使用する利点と、パフォーマンスを向上させるために文字列インターニングを使用する必要があるシナリオ/状況についても知りたいです。Jeffery Richter の CLR の本からインターンについて学びましたが、まだ混乱しており、詳しく知りたいと思っています。
[編集] 以下のようなサンプル コードで特定の質問をする:
private void MethodA()
{
string s = "String"; // line 1 - interned literal as explained in the answer
//s.intern(); // line 2 - what would happen in line 3 if we uncomment this line, will it make any difference?
}
private bool MethodB(string compareThis)
{
if (compareThis == "String") // line 3 - will this line use interning (with and without uncommenting line 2 above)?
{
return true;
}
return false;
}