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

Cannot view indexed property

P: n/a


I have created a collection of a custom class. Everything works fine (can add these items in a combo from withing a VB.NET application, for instance), but when looking at the collection from a VB.NET application in the Watch window, I cannot see the items of the collection. The message in the Watch window's "value" says: "<cannot view indexed property>." Below is the code I wrote.

Any idea of what is wrong? Or is the error message "correct"?

Thanks a lot.

public class Companies : IEnumerable {

ArrayList m_oCompanies = null;

public Companies() { // Nothing is done in the constructor. }
public void Add(Company oCompany) {...}
public Company this[int index] {
get { return (Company)m_oCompanies[index]; }

public int Count { ... }


public IEnumerator GetEnumerator() { return new CompaniesEnumerator(m_oCompanies); }

// Inner class implements IEnumerator interface:
class CompaniesEnumerator : IEnumerator {

int index;
ArrayList m_oCompanies;

public CompaniesEnumerator(ArrayList oCompanies) { this.m_oCompanies = oCompanies; }

public bool MoveNext() { return (++index < m_oCompanies.Count); }

public object Current {
get {
if (index < m_oCompanies.Count) return m_oCompanies[index];
return null; }

public void Reset() { ... }

Nov 15 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.