使用C#帮助Dictionary对象 [英] Help with Dictionary object using C#

查看:92
本文介绍了使用C#帮助Dictionary对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我一直在尝试提出最有效的逻辑/ 解决我的问题。

I have been trying to come up with most efficient logic/  solution for my problem.

以下是我的问题 - 并试图了解什么是最好的方法 

Below is my problem - and trying to understand what is the best approach 

我有字典对象,其中保存串 和类作为键值对。 由于关键需要是明确的,我在后缀处理密钥和类详细信息的计数。

I have Dictionary object which save string  and class as key value pair.  As key need to be distinct , I am suffixing deal with count for key and class details.

for。例如

我的班级存储基本的交易详情 即交易ID,交易ID等... -   下面说的是simpe Key valye对

My Class stores basic deal details  ie, deal id, trade id, etc... -   say below is simpe Key valye pair

Key,          价值(交易类)

Key,           Value ( deal class)

D1_01,       {D1,T1,dt1,dt2等..}

D1_01,      {D1, T1, dt1, dt2, etc..}

D1_02,       {D1,T2,dt1,dt2等。}

D1_02,       {D1,T2,dt1,dt2,etc..}

D1_03,       {D1,T3,dt1,dt2等..}

D1_03,       {D1,T3,dt1,dt2,etc..}

D2_01         {D2,T1,dt1,dt2等..}

D2_01        {D2,T1,dt1,dt2,etc..}

D3_01         {D3,T1,dt1,dt2等..}

D3_01         {D3,T1,dt1,dt2,etc..}

D2_02          {D2,T3,dt1,dt2等..}

D2_02          {D2,T3,dt1,dt2,etc..}

我现在的问题  因为我已经上过课,我正在尝试保存交易行业组合,即一笔交易以及许多贸易和其他细节如下所述。试图找到最好的方法/算法来实现?

My problem now  as I already have above class, I am trying to save Deal Trades combination ie, one deal and many trade and other detais as below.. Trying to undestand best possible approach / algorithm to be implimented?

键,值

D1  ,{{T1,dt1,dt2等..},{T2,dt1,dt2等..},{T3,dt1,dt2等...}}

D1  , {{T1,dt1,dt2,etc..},{T2,dt1,dt2,etc..},{T3,dt1,dt2,etc...}}

D2,{{T1,dt1,dt2等}},{T3,dt1,dt2,tct ..} }

D2, {{T1,dt1,dt2,etc..},{T3,dt1,dt2,tct..} }

D3,{T1,dt1,dt2,等等..}

D3 , {T1,dt1,dt2,etc..}

试图了解 这是我应该恭维的最佳方法吗? 任何指针/代码示例都会有很大帮助。

Trying to understand  wht is the best approach I should be impliment?  Any pointer / code examples would be great help.

问候,

推荐答案

您可以创建一个Dictionary< string,List< YourClass>>而不是字典< string,YourClass> - 这将允许您为每个键存储多个值。

You could create a Dictionary<string, List<YourClass>> instead of Dictionary<string, YourClass> - this would allow you to store multiple values per key.


这篇关于使用C#帮助Dictionary对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆