Gets the value associated with the specified key.
Syntax
Parameters
- key
- value
Return Value
true if the object that implements
IDictionary contains an element with the specified key; otherwise, false.
Example
Library/Library.Test/TestLurchTable.cs
C# | Copy Code |
---|
LurchTableTest<int, string> test = new LurchTableTest<int, string>();
for (int i = 0; i < 10; i++)
test.Add(i, i.ToString());
for (int i = 0; i < 10; i++)
Assert.IsTrue(test.ContainsKey(i));
string cmp;
for (int i = 0; i < 10; i++)
Assert.IsTrue(test.TryGetValue(i, out cmp) && cmp == i.ToString());
for (int i = 0; i < 10; i++)
Assert.IsTrue(test.Remove(i)); |
VB.NET | Copy Code |
---|
Dim test As New LurchTableTest(Of Integer, String)()
Dim i As Integer = 0
While i < 10
test.Add(i, i.ToString())
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim i As Integer = 0
While i < 10
Assert.IsTrue(test.ContainsKey(i))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim cmp As String
Dim i As Integer = 0
While i < 10
Assert.IsTrue(test.TryGetValue(i, cmp) AndAlso cmp = i.ToString())
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim i As Integer = 0
While i < 10
Assert.IsTrue(test.Remove(i))
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also