How to get get an element value of a hashtable 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("c", 101);
            hashtable.Add("c++", 102);
            hashtable.Add("java", 107);

            int value = (int)hashtable["c#"];
            Console.WriteLine(value);
        }
    }
}


/*
run:
     
100
 
*/

 



answered Feb 19, 2017 by avibootz

Related questions

1 answer 177 views
177 views asked Feb 20, 2017 by avibootz
1 answer 168 views
1 answer 114 views
114 views asked Apr 28, 2024 by avibootz
...