3
Answers

StringComparison

Maha

Maha

11y
1.6k
1
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));
}
}

Answers (3)