You need to sign in to do that
Don't have an account?
Rajus
Case insensitivity with mapkeys.
Hi All,
I have one simple map like below.
Map<string,string> keyAndValues = new Map<string,string>();
keyAndValues.put('ABCD','1234');
Now i want to check whether the string 'abcd' exists in Keys of Map or not.
I ll write like this,
if(keyAndValues.containskey('abcd')){
system.debug('Key exists in map');
}
Here It will return false as it ll check with case sensitivity.
But i want to ignore case sensitivity and want to search vth case insensivity.Is there any way to do like this.
If any one have idea please let me know.
Thanks in Advance.
Rajesh.
I have one simple map like below.
Map<string,string> keyAndValues = new Map<string,string>();
keyAndValues.put('ABCD','1234');
Now i want to check whether the string 'abcd' exists in Keys of Map or not.
I ll write like this,
if(keyAndValues.containskey('abcd')){
system.debug('Key exists in map');
}
Here It will return false as it ll check with case sensitivity.
But i want to ignore case sensitivity and want to search vth case insensivity.Is there any way to do like this.
If any one have idea please let me know.
Thanks in Advance.
Rajesh.
Map keys are case sensitive , you have to choose a format if you want case insensivity for e.g.
use tolowercase() while putting and searching in Map
Map<string,string> keyAndValues = new Map<string,string>();
String key1='ABcd';
keyAndValues.put(key1.tolowercase(),'1234');
if(keyAndValues.containskey('abcd'.tolowercase()){
system.debug('Key exists in map');
}