SCRIPTING.DICTIONARY in Dotnet
The code is a substitute in DOTNET for the component scripting.dictionary in VB
--------------------------------------------------------------------------------
Imports System.Collections.Hashtable
'''
''' Class Dictionary is used to provide the features of scripting.dictionary of vb
''' in Dotnet
'''
'''
Public Class Dictionary
Dim hash As Hashtable
Sub New()
hash = New Hashtable
End Sub
'''
''' Adds a new item to the dictionary(hashtable)
'''
''' key to access the values
''' value corresponding to the key
'''
Public Sub add(ByVal aKey As Object, ByVal aValue As Object)
hash.Add(aKey, aValue)
End Sub
'''
''' To check if a particular key exists
'''
''' key to access the values
'''Returns a boolean
'''
Public Function Exists(ByVal aKey As Object)
Return hash.Contains(aKey)
End Function
'''
''' Retrieves the value corresponding to the key
'''
''' key to access the values
'''returns value as object
'''
Public Function Item(ByVal aKey As Object)
Return hash.Item(aKey)
End Function
'''
''' Removes a particular item corresponding to the key from the dictionary
'''
''' key to access the values
'''
Public Sub Remove(ByVal aKey As Object)
hash.Remove(aKey)
End Sub
'''
''' Removes all items from the dictionary
'''
'''
Public Sub Removeall()
hash.Clear()
End Sub
'''
''' Gets an array of keys from the dictionary
'''
'''aKeylist array of keys as object
'''
Public Function Keys()
Dim aKeylist() As Object
ReDim aKeylist(hash.Keys.Count)
hash.Keys.CopyTo(aKeylist, 0)
Return aKeylist
End Function
'''
''' Returns the count of items in the dictionary
'''
''' Count as integer
'''
Public Function Count()
Return hash.Count
End Function
'''
''' Gets an array of Items from the dictionary
'''
'''aitemlist() an array of items(values)
'''
Public Function Items()
Dim aItemlist() As Object
ReDim aItemlist(hash.Values.Count)
hash.Values.CopyTo(aItemlist, 0)
Return aItemlist
End Function
End Class
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Imports System.Collections.Hashtable
'''
''' Class Dictionary is used to provide the features of scripting.dictionary of vb
''' in Dotnet
'''
'''
Public Class Dictionary
Dim hash As Hashtable
Sub New()
hash = New Hashtable
End Sub
'''
''' Adds a new item to the dictionary(hashtable)
'''
''' key to access the values
''' value corresponding to the key
'''
Public Sub add(ByVal aKey As Object, ByVal aValue As Object)
hash.Add(aKey, aValue)
End Sub
'''
''' To check if a particular key exists
'''
''' key to access the values
'''
'''
Public Function Exists(ByVal aKey As Object)
Return hash.Contains(aKey)
End Function
'''
''' Retrieves the value corresponding to the key
'''
''' key to access the values
'''
'''
Public Function Item(ByVal aKey As Object)
Return hash.Item(aKey)
End Function
'''
''' Removes a particular item corresponding to the key from the dictionary
'''
''' key to access the values
'''
Public Sub Remove(ByVal aKey As Object)
hash.Remove(aKey)
End Sub
'''
''' Removes all items from the dictionary
'''
'''
Public Sub Removeall()
hash.Clear()
End Sub
'''
''' Gets an array of keys from the dictionary
'''
'''
'''
Public Function Keys()
Dim aKeylist() As Object
ReDim aKeylist(hash.Keys.Count)
hash.Keys.CopyTo(aKeylist, 0)
Return aKeylist
End Function
'''
''' Returns the count of items in the dictionary
'''
'''
'''
Public Function Count()
Return hash.Count
End Function
'''
''' Gets an array of Items from the dictionary
'''
'''
'''
Public Function Items()
Dim aItemlist() As Object
ReDim aItemlist(hash.Values.Count)
hash.Values.CopyTo(aItemlist, 0)
Return aItemlist
End Function
End Class
--------------------------------------------------------------------------------------

0 Comments:
Post a Comment
<< Home