TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
326k
Case insensitive search
Oct 3 2012 10:03 PM
I this program when input is catch-22 relevant output is "not found". Please fix the error.
Also whether it is possible to use
Array.IndexOf
in this program.
using System;
using System.Collections; //needed to do case insensitive search
public class DebugSix04
{
public static void Main()
{
String[] books = { "Rich Dad", "Poor Dad", "
Catch-22
", "Harry Potter", "Programming Using C#", "Wizard of Oz", "The Deep" };
IComparer comparer = new CaseInsensitiveComparer(); //lower case input will be realized as upper case letter
Array.Sort(books, comparer);
Console.Write("What book are you looking for? ");
string enterBookName = Console.ReadLine();
int x = Array.BinarySearch(books, enterBookName, comparer);
if (x < 0)
Console.WriteLine("{0} not found", enterBookName);
else
Console.WriteLine("Yes, we carry {0}", books[x]);
Console.ReadKey();
}
}
Reply
Answers (
3
)
Fail Read Int64 value from binary file created by C++
C# working with a called process