2
Answers

Hashtable Problem

Photo of jaswant singh

jaswant singh

18y
2.1k
1
In Hashtable we can store two values like key and its value, but we want to store three values like Roll No, Name and Age is there any collection in c# to store that values from which we can access the detail based on Roll No

Answers (2)

0
Photo of Jerry
NA 2 0 18y
Hashtable only can store KEY and VALUE , if store three column and more, best change others mothod. though, you can store three column with one hashtable store in others(its all object type), but it's slowly than use datatable.
0
Photo of Scott Lysle
NA 25.7k 18.8m 18y
You can store an object in the hashtable; as such you can place a unique key on the key side and you can store an object in the value side.  That object can be an instance of a class that contains whatever variables you wish to store in the hashtable.  For example, if you had a class that contained some properties (say it held, name, rank, age, branch, and blood type as properties) you could put all of the values into an instance of the class and store the object in the hashtable, on the key side you could use a guid or someother unique ID to reference that particular object.