Click here to Skip to main content
11,487,406 members (70,697 online)
Click here to Skip to main content

Tagged as

Converting/Changing Types of Generic List

, 24 Mar 2010 CPOL 5.7K 2
Rate this:
Please Sign up or sign in to vote.
Suppose we have a base entity class called BaseEntity.We create a child Entity named Status inheriting BaseEntity public class Status: BaseEntityNow lets assume we have two Generic ListList mainList = new List();List childList;Now we want to...
Suppose we have a base entity class called BaseEntity.

We create a child Entity named Status inheriting BaseEntity

public class Status: BaseEntity

Now lets assume we have two Generic List

List<BaseEntity> mainList = new List<BaseEntity>();
List<Status> childList;

Now we want to convert mainList to childList and this can be converted easily by using Cast extension method that can be found under System.Linq

childList =  mainList.Cast<Status>().ToList();


Happy Conversion!!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mahmudul Haque Azad
Software Developer (Senior) Vizrt Bangladesh
Bangladesh Bangladesh
I am truly versatile and 360 degree Engineer having wide range of development experience in .NET and Java Platform. I am also proficient in system level programming in C++. To me technology is not at all a problem, it’s the client requirement that matters! That is I am ready and comfortable to use any technology to make the business of my client a success.

In my five years of experience I have the opportunities to work for fortune 500 companies of US and many renowned clients from Europe.

My Linkedin Profile: http://bd.linkedin.com/in/mahmudazad
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150520.1 | Last Updated 25 Mar 2010
Article Copyright 2010 by Mahmudul Haque Azad
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid