Getting Started with Adobe After Effects - Part 6: Motion Blur
This module helps you to share, discuss and learn interview questions and answers of different technologies

C# - Is it possible to add custom object as a key in HashTable,if so how to retrieve the stored value?

Apr 6 2012 12:00AM by Ramireddy   

Question

Is it possible to add custom object as a key in HashTable,if so how to retrieve the stored value?

Answer

Yes. Its certainly possible to store custom object as a key in hashtable. Since hashtable key is of type "object", we can use any type of object as key. I didn't find any usage with adding custom object as key. I presume this question is to test candidate analytic skills.

Eg:

        Hashtable ht = new Hashtable();
        Customer objCustomer = new Customer();
        objCustomer.CustomerID = 1;
        objCustomer.CustomerName = "Ram";
        ht.Add(objCustomer, objCustomer);
        Customer obj = ht[objCustomer] as Customer;

Read More..   [32134 clicks]

Published under: C# Interview Questions and Answers ·  ·  ·  · 


Ramireddy
2 · 41% · 12972
0
Liked
 
0
Asked



Submit

Your Comment


Sign Up or Login to post a comment.

"C# - Is it possible to add custom object as a key in HashTable,if so how to retrieve the stored value?" rated 5 out of 5 by 4 readers
C# - Is it possible to add custom object as a key in HashTable,if so how to retrieve the stored value? , 5.0 out of 5 based on 4 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]