blah blah blah is here! blah blah » Close

up0down
link

Hi all,
I am using C# generics in the followin example..
IList <db4o> native = db.Query <db4o>(delegate(db4o data)
{
return data.Points == 100;

});
Now, db4o is the class with following structure:
class db4o
{
string _name;
int _points;
and Points is :
public int Points
{
get
{
return _points;
}
}
Now, how exactly can I retrieve whts returned in "native"
Please let me know if i m missing some important piece of info I should be giving.. I didn't post the entire code to avoid confusion..
Many thanks,
Abhi

last answered 2 years ago

1 answers

up0down
link

Well, an IList<T> is also an IEnumerable<T> so you should be able to retrieve the results of that query using a foreach loop.
I'm assuming below that the db4o class also has a public Name property corresponding to the private _name field. There's no point in printing out the Points property value as it appears that the query will only return those objects which have a Points value of 100:
foreach(db4o data in native)
{
Console.WriteLine(data.Name);
}
An IList<T> also has an Item property so you can retrieve individual members of the list using C#'s indexer syntax:
db4o first = native[0];
db4o last = native[native.Count - 1];

up0down
link

thanks vulpes..
I will try this out..
Regards,
Abhi

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback