mList为列表List<MaterialInfo>,MaterialInfo为带ID成员的结构
可按下面两种方法改变列表的部分结构成员
for (int i = 0; i < mList.Count; i++)
{
if (mList[i].TID == oID)
{
MaterialInfo tmpInfo = mList[i];
tmpInfo.TID = nType.ID;
tmpInfo.ID = (nType.ID - mList[i].TID) * 1000 + mList[i].ID;
mList[i] = tmpInfo;
}
}
或者
while ((index = mList.FindIndex(mInfo => mInfo.TID == oID)) >= 0)
{
MaterialInfo tmpInfo = mList[index];
tmpInfo.TID = nType.ID;
tmpInfo.ID = (nType.ID - mList[index].TID) * 1000 + mList[index].ID;
mList[index] = tmpInfo;
}
可按下面两种方法改变列表的部分结构成员
for (int i = 0; i < mList.Count; i++)
{
if (mList[i].TID == oID)
{
MaterialInfo tmpInfo = mList[i];
tmpInfo.TID = nType.ID;
tmpInfo.ID = (nType.ID - mList[i].TID) * 1000 + mList[i].ID;
mList[i] = tmpInfo;
}
}
或者
while ((index = mList.FindIndex(mInfo => mInfo.TID == oID)) >= 0)
{
MaterialInfo tmpInfo = mList[index];
tmpInfo.TID = nType.ID;
tmpInfo.ID = (nType.ID - mList[index].TID) * 1000 + mList[index].ID;
mList[index] = tmpInfo;
}









