This program is given in the following website.
http://www.dotnetperls.com/stringcomparison
What is the meaning of the "CurrentCulture" and "InvariantCulture" . Problem is highlighted.
using System;
class Program
{
static void Main()
{
//
// Use the StringComparison enumerated type on the string input.
// ... The *IgnoreCase constants can be used with a lowercase parameter.
// ... Uppercase or mixed-case is fine too.
//
const string input = "Dot Net Perls";
Console.WriteLine(input.IndexOf("Net", StringComparison.Ordinal));
Console.WriteLine(input.IndexOf("net", StringComparison.OrdinalIgnoreCase));
Console.WriteLine(input.IndexOf("Net", StringComparison.CurrentCulture));
Console.WriteLine(input.IndexOf("net", StringComparison.CurrentCultureIgnoreCase));
Console.WriteLine(input.IndexOf("Net", StringComparison.InvariantCulture));
Console.WriteLine(input.IndexOf("net", StringComparison.InvariantCultureIgnoreCase));
}
}
Loading
Posted Oct 7, 2013, 2:16 PM
Vithal WadjePosted Oct 7, 2013, 1:15 PM
VulpesPosted Oct 7, 2013, 11:38 AM
In .NET, they are represented by the System.Globalization.CultureInfo class:
http://msdn.microsoft.com/en-us/library/System.Globalization.CultureInfo.aspx
The current culture is the culture used by the current thread. This will normally be the culture based on where you live and the language you speak. For example, if you live in Canada and speak English, it will be "en-CA".
The invariant culture is a special culture which isn't based on any specific culture or locale (i.e. it is culture independent) but is based on the English language and will never change.