Click here to Skip to main content
12,397,027 members (68,156 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

6.2K views
2 bookmarked
Posted

Converting/Changing Types of Generic List

, 24 Mar 2010 CPOL
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

You may also be interested in...

Comments and Discussions

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