Hello there,

i have a class user, and i also have implemented a collection for the same user class - users. users will store user objects. users collection class implements the generic collection class - collection<user>.

i want to cast the LINQ query result into an object of my collection class - users. Everytime i try explicit casting, it gives me a cannot class runtime exception.

i tried to implement the iEnumerable interface also in my users collection class, but still i could not cast the query result.

Now i have to do a for loop within the query result set, and fill up my own custom collection - users.

please help me regarding this, thanx in advnce.
Sanjay Sachdev

Welcome sanjaypsachdev,
Show us your code.

With the little information you have shown, maybe something like this is what you want:

List<User> users = new List<User>;

foreach(User person in TestUsers)
{
	users.Add((u => u.Name == person.Name).Single());
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.