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<>();
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.
var myHashMap = new Dictionary<string,object>();
Change the types string
and object
to whatever you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With