schimanski Well-Known Member Licensed User Longtime User Mar 23, 2017 #1 Is it possibel to combine Map.ContainsKey with EqualsIgnoreCase in order to check, if the key exists with another case or do I have to check each key himself in a loop? Code: Copy Dim exists As Boolean=False For Each key As String In Map1.Keys If key.EqualsIgnoreCase(Name)=True Then exists=True Exit End If Next If exists Then Log("Exists") Last edited: Mar 23, 2017
Is it possibel to combine Map.ContainsKey with EqualsIgnoreCase in order to check, if the key exists with another case or do I have to check each key himself in a loop? Code: Copy Dim exists As Boolean=False For Each key As String In Map1.Keys If key.EqualsIgnoreCase(Name)=True Then exists=True Exit End If Next If exists Then Log("Exists")
stevel05 Expert Licensed User Longtime User Mar 23, 2017 #2 The key is of type Object, so you cannot use String methods on it directly. I am assuming that you are not expecting there to be different cased versions of the same key otherwise your test may find the wrong match, so you could force the keys to all be the same case when you put them in the Map in the first place. Upvote 0
The key is of type Object, so you cannot use String methods on it directly. I am assuming that you are not expecting there to be different cased versions of the same key otherwise your test may find the wrong match, so you could force the keys to all be the same case when you put them in the Map in the first place.