473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

Jul 13 '06 #1
3 1457
Hello Shane,

Check out the System.Collections.Generic namespace and look up the documentation
on the new "Of" keyword.

-Boo
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

Jul 14 '06 #2
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)
--
David 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

Jul 14 '06 #3
Thanks for the info guys.

This feature was one of the items that had me chomping at the bit to
upgrade to 2.0

Shane

Jul 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Vinay Agarwal | last post by:
Hello, I am using Hashtable class in my application to store key/value pairs. It works great except the types returned are all objects. As a result, there are type-casts everywhere making the...
10
by: Bob | last post by:
This has been bugging me for a while now. GetType isn't availble for variables decalred as interface types, I have to DirectCast(somevariable, Object). In example: Sub SomeSub(ByVal...
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
4
by: Howard Kaikow | last post by:
I am trying to retrive some WMI properties using Option Strict On. This requires the use of InvokeMember. I know that there are alternative ways to get the values, but I want to learn how to...
4
by: zacks | last post by:
A common programming technique I use in VB is making a collection of structures. But if Option Strict is on (which I would prefer), the .Add that adds the structure to the collection is flagged...
9
by: YYZ | last post by:
After reading many messages in this group, it seems that the preferred setting for this is ON. Okay, I did that in my project (first with ..Net -- long time VB6 developer) and now a bunch of...
3
by: Rich | last post by:
This code worked before I added option strict. But I should do it correctly. option ... option Strict On Public Structure Itm Dim mailSvr As String ... Public Sub New(ByVal a1 As...
4
by: John | last post by:
Hi, I derived a class from the Hashtable class, with ISerializable implemented and the tag added. Everything works fine with one exception. I store the hashtable in ViewState, but on a...
0
by: Rajesh | last post by:
I am trying to use a simple custom type for saving the profile information of a user. The custom class inherits from the Hashtable. I am serializing the type as "Binary" in the provider sections of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.