|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strict type for Hashtable?I thought that arrays and hash tables could be strictly typed under 2.0
instead of just being objects, but I can't find any documentation. I want to have the values in a hash table designated as a string type, so that I don't have to keep doing something like: strSomething = CStr(hashtable(Key)) I'd rather have strSomething = hashtable(Key) Do the hashtables support this? If they do, what is the syntax? Thanks, Shane Hello Shane,
Check out the System.Collections.Generic namespace and look up the documentation on the new "Of" keyword. -Boo Show quoteHide quote > I thought that arrays and hash tables could be strictly typed under > 2.0 instead of just being objects, but I can't find any documentation. > > I want to have the values in a hash table designated as a string type, > so that I don't have to keep doing something like: > > strSomething = CStr(hashtable(Key)) > > I'd rather have > strSomething = hashtable(Key) > Do the hashtables support this? If they do, what is the syntax? > > Thanks, > Shane Yes, but the generic hashtable is the Dictionary(Of T) in the
System.Collections.Generic namespace. e.g., Dim GenericHashtable As New Dictionary(Of String) GenericHashtable.Add(somekey, somestring) Dim thisString = GenericHashtable(somekey) (also, List(Of T) is the generic replacement for ArrayList in 2.0) -- Show quoteHide quoteDavid Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C#/VB to C++ converter C# Code Metrics: Quick metrics for C# "Shane" wrote: > I thought that arrays and hash tables could be strictly typed under 2.0 > instead of just being objects, but I can't find any documentation. > > I want to have the values in a hash table designated as a string type, > so that I don't have to keep doing something like: > > strSomething = CStr(hashtable(Key)) > > I'd rather have > strSomething = hashtable(Key) > > Do the hashtables support this? If they do, what is the syntax? > > Thanks, > Shane > >
Calling Sub Procedure with a variable
ISO-8859-1 encoding of an xml string Deleting a Photo stored in a Picturebox Old Basic commands. Lookup table in a Label Lauching a form from another form is Recursive Procedures/Function what i need to solve my problem? consume web service via httpwebrequest Limit to range of colors displayed by Label control? How to remove an empty array ? |
|||||||||||||||||||||||