How to create a HashMap in C#
31,718
Solution 1
Look at Dictionary<key,value>
in the System.Collections.Generic
. It is the C# "parallel" (albeit having some differences, it is the closest to) of HashMap
in Java.
Solution 2
var myHashMap = new Dictionary<string,object>();
Change the types string
and object
to whatever you need.
Author by
kez
Currently looking for Full Time or Part Time Job that can work Remotely
Updated on July 09, 2022Comments
-
kez almost 2 years
I know we can create a HashMap in Java. But I want to create a HashMap in C# for my ASP.NET MVC project.
Is this possible to do? If yes, how?
In Java we can create a HashMap like this:
import java.util.HashMap; //... HashMap<Name, Value> myDictionary = new HashMap<>();
-
kez over 8 yearsthat means I have to go for dictionary
-
Karan Hotwani over 7 years@Ian, could you explain the differences?
-
Ian over 7 years@cskwrd here they are: stackoverflow.com/questions/1273139/…