ResourceManager.IgnoreCase Property
Assembly: mscorlib (in mscorlib.dll)
/** @property */ public boolean get_IgnoreCase () /** @property */ public void set_IgnoreCase (boolean value)
public function get IgnoreCase () : boolean public function set IgnoreCase (value : boolean)
Property Value
A Boolean value indicating whether the case of the resource names should be ignored.If the value of the IgnoreCase property is false, a resource with the name "Resource" is not equivalent to the resource with the name "resource". If IgnoreCase is true, a resource with the name "Resource" is equivalent to the resource with the name "resource". Note, however, that when IgnoreCase is true, the ResourceManager.GetString and ResourceManager.GetObject methods perform case-insensitive string comparisons using CultureInfo.InvariantCulture. The advantage is that results of case-insensitive string comparisons performed by these methods are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures.
For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). If IgnoreCase is true, this comparison succeeds.
Note |
|---|
| For performance reasons, it is best to always specify the correct case for your resource names. IgnoreCase can cause a significant workingset and performance hit. |
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
This seems to be incorrect:
For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). If IgnoreCase is true, this comparison succeeds.
First: ignore case implies 'case insensitive' so the comparison cannot both fail and succeed
0049 is uppercase of 0131
0130 is uppercase of 0069
case insensitive comparison: 0069 equals 0049?
so maybe if this is a typo (0049 should be 0130) it also makes no sense to state that due to different accents a different behavior emerges.
So maybe every comparison is AccentInsensitive? (why not add a IgnoreAccent Property)
Casing Conventions and the IgnoreCase Property
I'm not quite sure where the confusion arises, but the comparison does not both fail and succeed, nor is the example incorrect.
Typically, we expect case-insensitive comparisons to use the casing rules of the current culture. If that were the case, we would expect that if we search for a string resource named "Charİ" (where İ is U+0130) in a resource file in which the resource is actually named "Chari" (where i is U+0069), the comparison should succeed and the call to the GetString method should return a string. In fact, if we were to use ResourceManager to perform a case-insensitive search, the comparison would fail, and GetString("Charİ") would return an empty string. ResourceManager would find a culture-specific resource set for the tr-TR culture, but it would not be able to find a specific resource named "Charİ".
This happens because case-insensitive string comparison with ResourceManager is not culture-sensitive. Rather than using the casing conventions of the current culture, it uses the casing conventions of the invariant culture. Using the conventions of the invariant culture, the uppercase equivalent of i (U+0069) is always I (U+0049), and the uppercase equivalent of ı (U+0131) is always ı (U+0131, or the same character). This ensures that the behavior of ResourceManager is always consistent across cultures.
I hope that this helps to clarify the behavior of the IgnoreCase property.
--Ron Petrusha
Common Language Runtime User Education
Microsoft Corporation
- 6/17/2009
- wvl111
- 2/13/2012
- R Petrusha - MSFT
Note