English 中文(简体)
如何从TDictionary中获取钥匙?
原标题:How to get the key from a TDictionary?

我有<条码>TDictionary<TKeyClass,TValueClass>。

我想完成这样的事情。

for i := 0 to MyDictionary.Count -1 do
  ShowMessage(MyDictionary.Keys[i].AStringProperty)

如果我完全知道他们的话,我再也无法接触钥匙。

唯一的选择是建立<条码>TDictionary<TValueClass, TKeyValue>? 因此,我可以 lo笑钥匙?

我发现,我的工作是建立一个<代码>。 TList<TKeyClass>,但情况并非如此。

最佳回答

利用一名统计员。

for Key in MyDictionary.Keys do
  ShowMessage(Key.AStringProperty);

由于TDictionary是一片洗衣桌,你可以像一个阵列或TList那样,用惯性指数获取。 但是,一个统计员只做罚款。

问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签