I cannot get my array to convert to int. I tried some ways but always ran into errors. Here is my program as it stands now. Can anyone give me some pointers???
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;
namespace sortingarray
{
class Program
{
static void Main(string[] args)
{
String phoneareacode, state, line;
AreaCode myAreaCode;
bool isNum = false;
try
{
string[] strings = File.ReadAllLines("C:/CS280files/AreaCodes.csv");
string[][] unsortedarray = new string[strings.Length][];
for (int i = 0; i < strings.Length; i++)
{
unsortedarray[i] = strings[i].Split(',');
}
Array.Sort(unsortedarray, AreaCode.sortAreaCode());
for (int i = 0; i < unsortedarray.Length; i++)
{
phoneareacode = unsortedarray[i][0];
state = unsortedarray[i][1];
myAreaCode = new AreaCode(phoneareacode, state);
}
int searchAreaCode;
string searchString = Console.ReadLine();
isNum = Int32.TryParse(searchString, out searchAreaCode);
if (isNum)
{
int lowNum = 0;
int highNum = unsortedarray.Length - 1;
while (lowNum <= highNum)
{
int midNum = (lowNum + highNum) / 2;
if (searchAreaCode < unsortedarray[midNum])
{
highNum = midNum - 1;
}
else if (searchAreaCode > unsortedarray[midNum])
{
lowNum = midNum + 1;
}
else if (searchAreaCode = unsortedarray[midNum])
{
Console.WriteLine(" The state for Area Code {0} is: ", searchAreaCode);
return;
}
}
Console.WriteLine("Please enter a 3 digit area code!");
//Console.WriteLine(myAreaCode);
//Console.WriteLine();
//Console.ReadKey(true);
}
}
catch (IOException e)
{
Console.WriteLine(e);
}
}
}
}
This is the errors I am getting:
Visual Studio 2008\Projects\sortingarray\sortingarray\Program.cs(49,33): error CS0019: Operator '<' cannot be applied to operands of type 'int' and 'string[]'
Visual Studio 2008\Projects\sortingarray\sortingarray\Program.cs(53,38): error CS0019: Operator '>' cannot be applied to operands of type 'int' and 'string[]'
Visual Studio 2008\Projects\sortingarray\sortingarray\Program.cs(57,55): error CS0029: Cannot implicitly convert type 'string[]' to 'int'