How to use multiple types (string keys and int keys) 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(101, "c");
            hashtable.Add(102, "c++");
            hashtable.Add("java", 107);

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

            string s = (string)hashtable[102];
            Console.WriteLine(s);
        }
    }
}


/*
run:
     
100
c++
 
*/

 



answered Feb 19, 2017 by avibootz

Related questions

2 answers 210 views
1 answer 224 views
224 views asked Feb 20, 2017 by avibootz
1 answer 152 views
152 views asked Feb 20, 2017 by avibootz
1 answer 150 views
150 views asked May 10, 2020 by avibootz
5 answers 387 views
387 views asked Sep 11, 2019 by avibootz
...