shah

shah

  • NA
  • 42
  • 0

Variable declaration problem

Mar 22 2007 10:35 AM
I am working on QuickSort Console Application as i made quicksort function public static void Main(string[] args) { **************************************** int[] arr; int hi, lo = 0; getArray(arr); Sort(lo, hi,arr); //The problem lies here it is giving error on variable "hi" as how to determine its the last number in array *********************************** } public static void getArray(int [] arr) { try { int i; for (i = 0; i <= arr.Length; i++) { Console.WriteLine("Enter the numbers to sort:" +arr[i]); } } catch(Exception e) { Console.WriteLine("{0} Exception caught.", e); } displayArr(arr); } public static void displayArr(int [] arr) { for (int i = 0; i <= arr.Length; i++) { Console.Write("Sorted:" +arr[i]); } } // Please help me in this. Thanks,

Answers (5)