CSharpTest.Net
Add Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > LurchTable<TKey,TValue> Class : Add Method

key
value

Glossary Item Box

Adds an element with the provided key and value to the IDictionary.

Syntax

Visual Basic (Declaration) 
Public Sub Add( _
   ByVal key As TKey, _
   ByVal value As TValue _
) 
C# 
public void Add( 
   TKey key,
   TValue value
)

Parameters

key
value

Exceptions

ExceptionDescription
System.ArgumentOutOfRangeExceptionThe exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method.

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.NETCopy 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

Generated with Document! X 2011 by Innovasys