Resharper 建议这些变量:
List<string> senderDeviceIDList;
string senderDeviceID;
. . .
foreach (var item in PlatypiIds)
{
senderDeviceIDList = await GetSenderDeviceIDForSenderID(item);
senderDeviceID = senderDeviceIDList[0];
...可以在内部范围内声明,如下所示:
foreach (var item in PlatypiIds)
{
List<string> senderDeviceIDList = await GetSenderDeviceIDForSenderID(item);
string senderDeviceID = senderDeviceIDList[0];
...但这真的“更好”吗?这不会导致变量被声明 N 次(每个 foreach 循环一次)?