本文介绍了如何在C#中检索嵌套字典中最近添加的密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Storage类中有一个嵌套字典为



private static Dictionary< Guid,Dictionary< string,object>>商店{get;设置;}



我有另一个名为Handler.cs的类,其中我在存储类的静态字段中为GUID键添加值为



I have a nested dictionary in my Storage class as

private static Dictionary<Guid, Dictionary<string, object>> Store {get; set;}

I have another class named Handler.cs in which I add value to GUID key in static field of Storage class as

Guid clientId = Guid.NewGuid();
Session.SessionStore.Add(clientId, new Dictionary<string, object>());





我有另一个名为Executor.cs的类,其中我在Storage.cs类中调用add函数,根据Handler.cs中添加的GUID将值添加到Storage类中静态字段的子字典中





I have another class named Executor.cs in which I call add function in Storage.cs class to add values to sub dictionary of static field in Storage class based on GUID added in Handler.cs as

public Session sessionObject;
public void saveSession(HttpListenerContext contxt)
{
this.Storage.Add("Person", objPerson);
}



在Storage.cs我有功能添加为




In Storage.cs I have function Add as

public void Add(string key,object value)
        {
            
            //foreach (var item in SessionStore.Keys)
           // {
               
               // SessionStore[item].Add(key, value);
           // }
        }



但是在我的添加函数中,我只能传递子字典的键和值。我已经在Handler.cs中添加了GUID键。所以从字典列表中我应该如何找到最近添加的GUId?



我尝试过的事情:



我为GUID添加了值,并希望为最近添加的Guid


But in my add function I can pass only key and value of sub dictionary. I have already added the GUID key in Handler.cs. So from the dictionary list how should I find the recently added GUId?

What I have tried:

I added value to GUID and want to add sub dictionary values for the recently added Guid

推荐答案


这篇关于如何在C#中检索嵌套字典中最近添加的密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:27