locked
Searching for index in arraylist of structures RRS feed

  • Question

  • User1233494541 posted

    Hello All,  I have an arraylist of a structures as defined below and I trying to find the index of a particular name in the namevaluepair arraylist
    I try and use the indexof() method however it always returns -1. The arraylist does contain the data I am seaching for BTW.

    [thing is defined as a hashtable containing seperate structures for each users session]
    Done this way to hold variables accross pages and postbacks for each web user

    Public Shared Function IndexOf(ByVal ItemName As String, ByVal key As Object) As Integer
         Dim temp As ArrayList = thing.Item(key)
         
         Dim dex As Integer = temp.IndexOf(ItemName)
         Return dex
    End Function

    Public Structure NameValuePair
         Public name As String
         Public value As String
    End
    Structure

    Wednesday, June 11, 2008 12:46 PM

Answers

  • User1788825812 posted

    Have you looked at using Session to store these values which will work per user instead of creating your own way to do this? If you are not wanting to save complex types and just wanted to save a string value then you could use Cookies. Both of these ways has their advantages/disadvantages over each other but I think it would be better than creating your own way of doing this and they both will store variables across pages and postbacks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 11, 2008 11:04 PM