IDictionary C#vs Map Java? [英] IDictionary C# vs Map Java ?

查看:71
本文介绍了IDictionary C#vs Map Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有以下代码:

Hello guys, i have the following code:

    private Map map;


public SomeFunction(Map<?,Integer> map, boolean acsending){
            Set mapEntrySet=map.entrySet();
        Entry entry;
}



我正在尝试将其转换为C#,我读过很多主题,有些人认为地图是等于C#中的IDictionary,但是Set和Entry怎么样?



我怎么能转换它?

谢谢:)


and i''m trying to convert it to C#, i''ve read many topics, some suggested that the Map is equal to IDictionary in C#, but what about Set and Entry??

how could i convert it??
thanks :)

推荐答案

Hello Abdullatif



Java Map或C#IDictionary都代表一个键值对集合。在Java中,Map.entrySet以Set的形式返回这些键值对的集合,该集合是没有重复值的集合。键值对本身由Entry表示,它是Map中的子接口。 IDictionary接口的Map.Entry等效于DictionaryEntry。



例如枚举地图中的所有字符串值

Hello Abdullatif

Java Map or C# IDictionary both represents a key value pair collection. In Java Map.entrySet returns the collection of these key value pairs in form of a Set which is collection with no duplicate values. The Key Value pair itself is represented by Entry which is child interface in Map. The equivalent of Map.Entry for IDictionary Interface is DictionaryEntry.

e.g. Enumerate All String values in a Map
for (Map.Entry<string,> entry : mymap.entrySet())
    System.out.println("Value for Key '" + entry.getKey() + "' is " + entry.getValue());





C#中的等价代码将是



Equivalent code in C# would be

foreach (DictionaryEntry de in myDictionary)
    Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);





问候,



regards,


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

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