我的字典聲明如下如何在C#
public static Dictionary<object, DataInfo> DataDic = new Dictionary<object, DataInfo>();
public class DataInfo
{
public string DSPER; // Data Sample Period
public int TOTSMP; // Total Samples to be made
public int REPGSZ; // Report Group Size
public List<int> IDList; // Array List to collect all the enabled IDs
}
功能InitDataDic
下面叫,我怎麼能寫的重新分配tdi.TOTSMP後的字典.Remove()
和.Add()
的代碼更新複雜的字典值的某些部分= 0在true
條件下以簡單的方式。
public void InitDataDic (object objid, DataInfo datainfo, int totsmp)
{
DataInfo tdi = new DataInfo();
object trid = objid;
tdi = datainfo;
if (DataDic.ContainsKey(trid) == true)
{
DataDic.Remove(trid); // here, i mentioned above
tdi.TOTSMP = 0;
DataDic.Add(trid, tdi); // here, i mentioned above
}
else
{
tdi.TOTSMP = topsmp;
DataDic.Add(trid, tdi);
}
}
有沒有人建議您致電領域,而不是''DataSamplePeriod' DSPER'(這是不可讀和神祕的),同樣爲所有其他人呢? – Timwi 2010-08-30 07:28:48
@Timwi,簡短的'DSPER'來自SEMI E5標準手冊。當然這是有點難以理解和神祕的。實際上,它非常好地匹配了標準手冊中定義的參數。謝謝。 – 2010-08-31 05:37:15
因此,你永遠在別人的錯誤,而不是主動去解決它,你可以。 – Timwi 2010-08-31 07:40:19