私は以下を持っています:
- GlobalStringsと呼ばれるメインリスト
- localStringsと呼ばれる別のリスト
たとえばループでは:
List<string> GlobalStrings = new List<string>();
List<string> localStrings = new List<string>();
for(x=1;x<10;x++)
{
localStrings.Add("some value");
localStrings.Add("some value");
}
// Want to append localStrings to GlobalStrings as easily as possible
3
あなたはそれを間違っています、ループの
—
Wassim AZIRAR
localStrings = new List<string>;
前に置くべきですfor
ワッシム、それが彼がローカルとグローバルを区別する理由だと思います。localStringsはforループスコープに対してローカルであり、GlobalStringsはグローバルスコープ内にあります。
—
ダグルームズ2015年
これは、以来、明らかにあなた可能性だけで、(招待状が全くワッシムのようなコメントをwrongheadedこと)が悪い例です
—
ジム・Balter
Add
へGlobalStrings
の代わりにlocalStrings
。ループするFWIWは9回しか実行されません。ベターだろうfor (int x = 0; x < 10; ++x) {var localStrings = GetAListOfStrings(); /* append those to GlobalStrings */}