How to get hashtable value from key in C#

1 Answer

0 votes
using System;
using System.Collections;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable hashtable = new Hashtable();

            hashtable.Add("c#", 100);
            hashtable.Add(101, "c");
            hashtable.Add(102, "c++");
            hashtable.Add("java", 107);

            Console.WriteLine(hashtable[102]);

            string value = hashtable[102] as string;

            Console.WriteLine(value);
        }
    }
}


/*
run:
     
c++
 
*/

 



answered Feb 20, 2017 by avibootz

Related questions

1 answer 167 views
1 answer 173 views
2 answers 234 views
1 answer 137 views
1 answer 169 views
1 answer 174 views
...