This program will help you find given string location inside another string location with ignoring the case.
C# Code to use IndexOf to Ignore Case
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
string string1 = "C# Tutorial by CSharpTalk.com.";
string string2 = "BY";
CompareInfo myCompare = CultureInfo.InvariantCulture.CompareInfo;
int Pos = myCompare.IndexOf(string1, string2, CompareOptions.IgnoreCase);
Console.WriteLine("String Found at: " + Pos);
Console.ReadLine();
}
}
}
Output:
No comments:
Post a Comment