pls a little help to a :-/guy,

In my main method am working on a collection of numbers in an array.
I want to sort the numbers efter then would like to see which index number holds the value 14.

As you can see in what i did so far sort works all right in the background, and returns index number 7 as what holda 14.

But there are two other 14 teens . my question then is how can I go about this to show the other index place numbers of other 14 teens?

this is what i did .

int[]  nums  =  {  5,  14,    3,    9,  8,  17,  14,  24,  -1,  14};    
            //  Searching  for  all index number of 14s.    
          int  idx  =  Array.BinarySearch(nums,  14);    
          Console.WriteLine("Index  of  14  is  "  +  idx);

if some one could help me out. My sincere thanks .

Look at Array.IndexOf and Array.LastIndexOf , which will give you the index of the first and last occurrence of the int in your array.

To fetch all the occurrences, you can use a loop as well. Something like this:

ArrayList indx = new ArrayList();
for (int i=0;i<nums.Length;i++)
    if (nums[i] == 14)

At the end of the loop, the ArrayList indx will hold all the indexes that hold the number 14. You can read more about ArrayList. you can do a lot more with it as compared to Array.

This question has already been answered. Start a new discussion instead.