I have a address class with properties type_id, address, city, state, country, postal_code. The user can store more than one addresses, and i store the addresses in the session as an arraylist like below and i use vb.net
dim addresses as new arraylist
addresses = session("Addresses")
dim addressinstance as new Address() ' create new instance Class
addressinstance.type_id = 100
addressinstance.address = something.....
session("addesses") = addresses
And i need to check if the user has entered the address twice for the same time, and return an error if so. to do this i wrote a function like
Public Shared Function isDuplicate(ByVal input As Int32, ByVal inputArray As ArrayList, ByVal element As String) As ERROR_CODES
Dim arrayEnumerator As IEnumerator = inputArray.GetEnumerator
Dim arrayEnumList As ArrayList
If arrayEnumerator.Current.type_ID = input Then
where input the type_id i need to check, InputArray is the ArrayList , and element has string "TYPE_ID" which the property of Address class.
this works fine. But i need to generalize it to check against any Ararylist which are basically instances of other classes. I have similar for phone etc., i do not want to repeat the code for all. The problem i have is the part that says
If arrayEnumerator.Current.type_ID = input , here instead of type_ID which is only for address class, I need use the element parameter of the function call, since the property i need to check may not neccessarily be "TYPE_ID".
soemthing like arrayEnumerator.Current.element = input.