Hash table , Dictionary C#
/Hashtable
Hashtable table = new Hashtable();
table.Add("userName", "sudheer");
table.Add("Password", "Reddy");
table.Add("Age", "32");
table.Add("Country", "India");
Console.ReadKey();
Console.WriteLine(table.Count);
foreach (var key in table.Keys)
Console.WriteLine(" " + key + ": " + table[key]);
//Dictionary
String[] names1 = new string[] { "sudheer", "kumar", "reddy", "chittireddy" };
String[] names2 = new string[] { "suresh", "kumar", "reddy", "chittireddy" };
String[] names3 = new string[] { "sunil", "kumar", "reddy", "chittireddy" };
String[] names4 = new string[] { "Gopal", "kumar", "reddy", "chittireddy" };
Dictionary<int,String[]>dict = new Dictionary<int, String[]>();
dict.Add(1, names1);
dict.Add(2, names2);
dict.Add(3, names3);
dict.Add(4, names4);
foreach (var value in dict)
{
String[] userinfo = value.Value;
foreach (var user in userinfo)
{
Console.WriteLine(user);
}
}
Console.ReadKey();
Hashtable table = new Hashtable();
table.Add("userName", "sudheer");
table.Add("Password", "Reddy");
table.Add("Age", "32");
table.Add("Country", "India");
Console.ReadKey();
Console.WriteLine(table.Count);
foreach (var key in table.Keys)
Console.WriteLine(" " + key + ": " + table[key]);
//Dictionary
String[] names1 = new string[] { "sudheer", "kumar", "reddy", "chittireddy" };
String[] names2 = new string[] { "suresh", "kumar", "reddy", "chittireddy" };
String[] names3 = new string[] { "sunil", "kumar", "reddy", "chittireddy" };
String[] names4 = new string[] { "Gopal", "kumar", "reddy", "chittireddy" };
Dictionary<int,String[]>dict = new Dictionary<int, String[]>();
dict.Add(1, names1);
dict.Add(2, names2);
dict.Add(3, names3);
dict.Add(4, names4);
foreach (var value in dict)
{
String[] userinfo = value.Value;
foreach (var user in userinfo)
{
Console.WriteLine(user);
}
}
Console.ReadKey();
Comments
Post a Comment