c# hashtable
using System;
using System.Collections;
namespace CollectionsApplication {
class Program {
static void Main(string[] args) {
Hashtable ht = new Hashtable();
ht.Add("001", "Zara Ali");
ht.Add("002", "Abida Rehman");
ht.Add("003", "Joe Holzner");
ht.Add("004", "Mausam Benazir Nur");
ht.Add("005", "M. Amlan");
ht.Add("006", "M. Arif");
ht.Add("007", "Ritesh Saikia");
if (ht.ContainsValue("Nuha Ali")) {
Console.WriteLine("This student name is already in the list");
} else {
ht.Add("008", "Nuha Ali");
}
// Get a collection of the keys.
ICollection key = ht.Keys;
foreach (string k in key) {
Console.WriteLine(k + ": " + ht[k]);
}
Console.ReadKey();
}
}
}
3.89
9
- HashTable don't have null key, sychronized(thread-safe)
good for parallel testing
Thank you!
9
0
Are there any code examples left?
New code examples in category C#
-
C# 2022-03-28 00:40:23 c# movement script
-
C# 2022-03-28 00:15:17 Delete last modification on EntityFramework Core
-
C# 2022-03-28 00:15:02 file.create folder c#
-
C# 2022-03-27 21:25:04 Error inflating class android.support.constraint.ConstraintLayout
-
C# 2022-03-27 21:15:02 top down shooting in unity 2D
-
C# 2022-03-27 20:50:02 c# remove invalid directory characters
-
C# 2022-03-27 20:30:07 how to use K2 games Games parallax background
-
C# 2022-03-27 20:25:10 c# replace crlf
-
C# 2022-03-27 20:25:09 keycode for left mouse click unity