Strict type for Hashtable?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shane

    #1

    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

  • GhostInAK

    #2
    Re: Strict type for Hashtable?

    Hello Shane,

    Check out the System.Collecti ons.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

    Comment

    • David Anton

      #3
      RE: Strict type for Hashtable?

      Yes, but the generic hashtable is the Dictionary(Of T) in the
      System.Collecti ons.Generic namespace.
      e.g.,
      Dim GenericHashtabl e As New Dictionary(Of String)
      GenericHashtabl e.Add(somekey, somestring)
      Dim thisString = GenericHashtabl e(somekey)

      (also, List(Of T) is the generic replacement for ArrayList in 2.0)
      --
      David Anton
      Source code converters: Convert between C#, C++, Java, and VB with the most accurate and reliable source code converters

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

      Comment

      • Shane

        #4
        Re: Strict type for Hashtable?

        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

        Comment

        Working...