Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Last active September 21, 2015 16:13
Show Gist options
  • Save ChrisMoney/79f0a3d2d7dc795a3243 to your computer and use it in GitHub Desktop.
Save ChrisMoney/79f0a3d2d7dc795a3243 to your computer and use it in GitHub Desktop.
Hash - C#
using System;
using System.Collections;
class Program
{
static Hashtable GetHashtable()
{
Hashtable hashtable = new Hashtable();
hashtable.Add(300, "Carrot");
hashtable.Add("Area", 1000);
return hashtable;
}
static void Main()
{
Hashtable hashtable = GetHashtable();
string value1 = (string)hashtable[300];
Console.WriteLine(value1);
int value2 = (int)hashtable["Area"];
Console.WriteLine(value2);
}
}
//Output
Carrot
1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment