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 192 views
1 answer 212 views
212 views asked Feb 20, 2017 by avibootz
1 answer 141 views
141 views asked Feb 20, 2017 by avibootz
1 answer 139 views
139 views asked May 10, 2020 by avibootz
5 answers 369 views
369 views asked Sep 11, 2019 by avibootz
...