Re: singleton ienumerable, need to add more...
- From: "Marc Gravell" <marc.gravell@xxxxxxxxx>
- Date: 16 Nov 2006 14:28:33 -0800
OK, one thing at a time.
I think the "indexer" syntax you are looking for is:
public Folder this[int rowIndex]
{
get
{
return new Folder(DT.Rows[rowIndex]);
}
}
you can then access Folders.SiteFolders[4]; (etc)
Note that I tweaked the return type to be useful. However, the bigger
points:
* it is unusual for something to be enumerable and an enumerator; I
suspect you just mean IEnumerable or IEnumerable<Folder>
* Thread safety: since you appear new to C# this probably won't be an
issue, but in general static methods should be thread safe, which
SiteFolders isn't
* could just pass up the obtained enumerator, rather than the
smoke'n'mirrors?
* each call to Current returns a different object; this could get very,
very confusing, and lead to all sorts of fun
* minor comment issue: this is merely a cast, not polymorphism
* not sure this is really suited to a singleton pattern - although that
might just be that I don't know enough about the context, so I'll give
you the benefit of the doubt
Given that you seem to have a wrapper object (Folder), there may be a
lot of benefit in moving to a List<Folder> implementation; this would
allow you to hand over a simple enumerator without all the fuss, and
your Folder objects would only exist once each- you'd just loop over
the DataTable.
Let me know if you want more help,
Marc
.
- Follow-Ups:
- Re: singleton ienumerable, need to add more...
- From: David Colliver
- Re: singleton ienumerable, need to add more...
- From: David Colliver
- Re: singleton ienumerable, need to add more...
- References:
- singleton ienumerable, need to add more...
- From: David
- singleton ienumerable, need to add more...
- Prev by Date: Re: Convert.ToString() Base Limitations
- Next by Date: Problem appending a new element to xml file...
- Previous by thread: singleton ienumerable, need to add more...
- Next by thread: Re: singleton ienumerable, need to add more...
- Index(es):
Relevant Pages
|