By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,677 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,677 IT Pros & Developers. It's quick & easy.

Array Indexes

P: 17
i would like some help on how to retrieve array indexes. i have the following scenario:

List <string> alphabet = new ....;


i have populated a new arraylist which only identifies distinct/unique alphabet items in the firt array e.g. it is able to list contents a, b and c only.

my challenge is how do i identify occurence index for the unique array list so that it displays and shows that
item "a" exists on index 0,2,4
item "b" exists on index 1
item "c" exists on index 3

thank you..
Aug 30 '10 #1
Share this Question
Share on Google+
1 Reply

P: 4
Expand|Select|Wrap|Line Numbers
  1. public int[] indexesOf(List list, String string) {
  2.   List<int> result = new List<int>();
  3.   for (int i = 0; i < list.Count; i++) { 
  4.    if (list[i] == string) {
  5.         result.Add(i);
  6.    }
  7.   }
  8.   return result.ToArray();
  9. }
Aug 30 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.