读书人

Generics.Collections TDictionary,该

发布时间: 2012-04-17 15:06:33 作者: rapoo

Generics.Collections TDictionary
Delphi Generics.Collections单元中
TDictionary<TKey,TValue> = class(TEnumerable<TPair<TKey,TValue>>)
private
type
TItem = record
HashCode: Integer;
Key: TKey;
Value: TValue;
end;
TItemArray = array of TItem;

如何改变 Dictionary中的key值?

[解决办法]

Delphi(Pascal) code
var  a : TDictionary<integer,integer>;  b : TPair<integer,integer>;begin  a := TDictionary<integer,integer>.create;  try    a.Add(1, 1);    b.Key := 1;    b.Value := a.Items[b.Key];    a.Remove(b.Key);    b.Key := 2;    a.Add(b.Key, b.Value);    Caption := IntToStr(a.Items[2]);  finally    a.Free;  end; 

读书人网 >.NET

热点推荐