تفاوت ()string.ToLower با ()string.ToLowerInvariant در C#
بسته به فرهنگ فعلی( current culture)، ToLower ممکن است یک حرف کوچک خاص فرهنگ تولید کند که شما انتظارش را ندارید. مانند تولید ınfo
بدون نقطه روی i به جای info
و در نتیجه مختل کردن مقایسه رشته ها.
به همین دلیل،از ToLowerInvariant باید در هر داده غیر خاص زبان استفاده شود. وقتی ممکن است ورودی کاربر به زبان مادری/مجموعه نویسههای آنها باشد، معمولاً تنها زمانی است که از ToLower استفاده میکنید.
Depending on the current culture, ToLower might produce a culture specific lowercase letter, that you aren't expecting. Such as producing ınfo without the dot on the i instead of info and thus mucking up string comparisons. For that reason, ToLowerInvariant should be used on any non-language-specific data. When you might have user input that might be in their native language/character-set, would generally be the only time you use ToLower.