Convert array string into integer
This program has to finds whether a book dealer carries a requested book. When using BinarySearch() method both argument inside the parenthesis should be in integer.
How to convert string array ("books") into integer array.
using System;
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" };
Console.Write("What book are you looking for? ");
int enterBookName = Convert.ToInt32(Console.ReadLine());
int x = Array.BinarySearch(books, enterBookName);
if (x > 0)
Console.WriteLine("{0} not found", enterBookName);
else
Console.WriteLine("Yes, we carry {0}", enterBookName);
}
}