Q qsrtech Active Member Licensed User Longtime User Apr 8, 2013 #1 Hi, not sure if this is by design but I encountered a situation where I was adding an integer value through a variable to a list object, which incidentally was cast from a string. I later tried to use Indexof with a string variable and although the value was theorectically in the list it returned -1 Code: Copy Dm MyList as List MyList.Iinitialize ... Dim ListValue as int ListValue=12345 MyList.Add(ListValue) ... Dim line() as string=regex.split(tab,result) dim index as int index=MyList.IndexOf(line(0)) 'line(0)=12345 Do we have to always use indexof with the same variable type as was originally inserted? Last edited: Apr 8, 2013
Hi, not sure if this is by design but I encountered a situation where I was adding an integer value through a variable to a list object, which incidentally was cast from a string. I later tried to use Indexof with a string variable and although the value was theorectically in the list it returned -1 Code: Copy Dm MyList as List MyList.Iinitialize ... Dim ListValue as int ListValue=12345 MyList.Add(ListValue) ... Dim line() as string=regex.split(tab,result) dim index as int index=MyList.IndexOf(line(0)) 'line(0)=12345 Do we have to always use indexof with the same variable type as was originally inserted?
Erel B4X founder Staff member Licensed User Longtime User Apr 8, 2013 #2 Do we have to always use indexof with the same variable type as was originally inserted? Click to expand... Yes. A list can hold ANY type of object (including other collections).
Do we have to always use indexof with the same variable type as was originally inserted? Click to expand... Yes. A list can hold ANY type of object (including other collections).