Geeks With Blogs
Vamsidhar Mamillapalli
As a developer, we play more with IList<T>. With the help of Generics and using Enumerable.OfType<TResult> we can retrieve objects of type<T> from List<T> in more elegant way.  

Example: 

Lets assume we have a List<T> where T is of type Person. Student and Employee are two classes derived from Person. 
List<Person> personlist = new List<Person>();
        personlist.Add(new Student());
        personlist.Add(new Person());
        personlist.Add(new Student());
        personlist.Add(new Person());

Now, to get Person of type Student, below is method using Generics and LINQ
   
  public IList<T> GetList<T>() where T: Person
 {
       return personlist.OfType<T>().ToList();
 }

  now, to get List<Employee>  from personlist query like below
 
 List<Employee> employeelist = GetList<Employee>();
Posted on Saturday, February 16, 2013 9:16 PM | Back to top


Comments on this post: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Hi Vamsidhar,

My name is Anna Holland, and I am a Marketing Coordinator at Syncfusion. I am reaching out to see if you would blog about one of our free e-books, collectively known as the Succinctly series. It is a great way to add value to your personal website. There are many topics to choose from; you can check out our complete list of books at http://www.syncfusion.com/resources/techportal/ebooks. They are written by talented experts who are personally selected by Syncfusion. Our goal for each book is to take 500+ pages of information on a topic such as ASP.NET MVC, jQuery, HTTP, etc., and condense it to about 100 pages of essentials. If you choose to blog about one of our e-books, products, or any other Syncfusion resource, you will receive a free $20 Amazon gift card. Please let me know if you have any questions. Thank you for your time, and I look forward to hearing from you!

Regards,

-Anna
Left by Anna Holland on Feb 22, 2013 2:48 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
The provided information is good for students who want to identify more accurate methods for observation.
buy affordable dissertation
Left by Alison Cerys on Nov 19, 2014 12:39 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
I hope you like it. Suppose we have a List. This design is very simple, after your article, soon learned. Luminous Swiss ETA Movement
Left by batty on Dec 16, 2014 5:04 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
I do not know this, but I know this is very good ! For watches aigner
Left by aigner on Dec 22, 2014 1:53 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
These Generics and using Enumerable good for new developers and you describe very elegant wayl
UK Dissertation
Left by Drew Erick on Mar 16, 2015 4:25 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Hey i think its great solution for us.But need more explain.Explain is too short.So please provide it.
_____________
Aero AUto
Website: auto transport los angeles
California.
Left by movemein on Jun 27, 2015 6:12 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...

Hey i think its great solution for us.But need more explain.
Left by Automatic Movement watch on Jul 09, 2015 11:29 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
I am not so much expert in tech related but after reading this post i believe that its very important post for tech user.Hope your tips will be helpful.___computer repair Boynton beach, Florida
Left by Anson on Sep 17, 2015 12:07 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Great post
Left by GReat on Dec 21, 2015 3:44 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This website is really well information provide to its customer. Therefore its visitors spread the value when someone needs to know about best site according to interesting information. Essay writing website for students. Thanks for this article to share with us.
Left by Jack Morcal on Jan 19, 2016 4:42 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
I guide the students that how they can pass the exams and how can they get the certification for the latest knowledge this certification exam students click at exam or visit its certification its better for your bright future and will helpful to attain the Pass4sure HP2-B115 PDF
Left by Pass4sure Study Guide on Mar 01, 2016 6:33 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Thanks a lot.
Left by jenny on Jul 20, 2016 3:12 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Much obliged to you for letting me went to the home of so sacred and extraordinary online journal! Different specialists in this field don't see this. You ought to proceed with your writing.I trust you have an immense harvest! Numerous individuals likely will share your written work. Bottoms up! Essay Help - True Essay Help
Left by Evie Waters on Aug 20, 2016 4:10 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
:I really enjoyed how amazingly you noticed the micro changes and wrote them in broader way. I found this as an informative and captivating post, so I think it is very helpful and acquainted. I would like to thank you for the endeavor you have made in this piece.
Custom Coursework Writing Help
Left by CurtisA on Aug 23, 2016 6:50 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Great Post! According to my view you have provided the best solution to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics. This post is very helpful for the developers and will also help the students who wants to become a developer.
Assignment Writing Service
Left by John Noels on Sep 23, 2016 11:52 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This subject should be discussed to spread the awareness. Netflix Vs Hulu Plus
Left by Jacobs on Dec 10, 2016 1:28 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Google asdasdasfasd
<a href="https://www.google.com”>Google 123456
[url=https://www.google.com]Google[/url] asdasdasd
Left by strong on Jan 13, 2017 11:16 AM

# term paper writing service
Requesting Gravatar...
I personally like your post,term paper writing service
you have shared good article. It will help me in great deal.
Left by Albert Thomas on Jan 26, 2017 10:24 AM

# Write my custom paper for me
Requesting Gravatar...
This site is truly well data give to its client. Write my custom paper for me .Along these lines its guests spread the esteem when somebody has to think about best site as per intriguing information. Thanks for this article to impart to us.
Left by John Marshal on Feb 02, 2017 12:41 PM

# re: How to Retrieve subclass objects of type
Requesting Gravatar...
Given a simple inheritance hierarchy: Person -> Student, Teacher, Staff Dissertation Help UK Review Say I have a list of Persons, L. In that list are some Students, Teachers, and Staff.
Using LINQ and C#, is there a way I could write a method that could retrieve only a particular type of person?
I know I can do something like:
Left by Billy Fowler on Feb 10, 2017 12:57 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Using LINQ and C#, is there a way I could write a method that might retrieve simplest a particular sort of character?

I recognise essay help uk
I can do some thing like:
var peopleIWant = L.OfType< Teacher >();
Left by James M.oliver on Feb 27, 2017 2:46 PM

# Help With MBA Dissertation Writing
Requesting Gravatar...
The leading assignment help UK firm offers state of the art services to its clients with a promise of delivering all the required work well within the deadline.
Left by Tito Boyer on Mar 04, 2017 3:49 PM

# Help With Taxation Law Assignment
Requesting Gravatar...
Good way of telling, good post to take facts regarding my presentation subject matter, which i am going to deliver in my college Help With Taxation Law Assignment

Left by Help With Taxation Law Assignmen on Mar 07, 2017 2:34 PM

# Help With VBA Excel Project VB Homework
Requesting Gravatar...
Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.
Left by Help With VBA Excel Project VB H on Mar 07, 2017 6:13 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This is an excellent publish. This publish gives truly top quality details. I’m definitely going to look into it. Really very useful guidelines are supplied here. Thank you so much. Keep up the best performs. Buy Dissertation Online
Left by Johny Thomas on Mar 10, 2017 12:34 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
I have got a lot of useful information on the similar topics from your blogs. It is extremely good from your side to share the details about the different programming methods and the installation tutorials here. Provided information will be helpful for many students as well. Paris City Tours
Left by lionel on Mar 17, 2017 4:34 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
It is good to do it this way but when you are doing a professional work, you will have to add some different names to the variables since there will be many categories of variables with the same type. I am just trying to make you understand about it. auto repair huntington beach
Left by Griffin Hughes on Mar 28, 2017 2:48 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
According to my read, you've got provided the simplest resolution to Retrieve taxonomic group objects of the sort from List exploitation LINQ and Generics.
UK Essay Writing
Left by Elise Ward on Apr 11, 2017 12:46 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This is an excellent publish. This publish gives truly top quality details. I’m definitely going to look into it. Really very useful guidelines are supplied here. Thank you so much. Keep up the best performs. research paper writing help
Left by Alvina Ria on Apr 12, 2017 5:15 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
In case, you want me. And let me realize in case you get maintain of your subclass objects of type. Need mba essay help at the targets for the assembly. I got a thumbs-up from the relaxation of Generics and using Enumerable I'm simply out with some pals.
Left by Evina Malkov on Apr 14, 2017 4:29 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Much obliged to you for letting me went to the home of so sacred and extraordinary online journal! Different specialists in this field don't see this. You ought to proceed with your writing.I trust you have an immense harvest! Numerous individuals likely will share your written work. Bottoms up! academic thesis paper
Left by renee betrand on Apr 17, 2017 1:17 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This is really a good Search Engine for students
Left by Josh Hastings on Apr 19, 2017 12:19 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
A lot of thanks for this brilliant post! lots of points have extremely useful. Hopefully you'll continue sharing your knowledge around Text Messaging Online. bulk messaging services
Left by David joe on Apr 19, 2017 6:37 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This information can be very helpful for those people who are working in the programming section. When we are dealing with programs it is obvious that most of them deal with small errors that can cause problems to your website. cable management solutions
Left by Nikita on Apr 21, 2017 5:28 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
I truly delighted in how incredibly you saw the miniaturized scale changes and kept in touch with them in more extensive way. I discovered this as a useful and important post, so I think it is exceptionally useful and familiar. I might want to thank you for the attempt you have made in this piece.
British Essay Writing
Left by Kenneth K.Gidley on Apr 25, 2017 10:31 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Using LINQ and C#, is there a way I could write a method that might retrieve simplest a particular sort of character?
You ought to proceed with your writing.I trust you have an immense harvest! Numerous individuals likely will share your written work. Bottoms up. <a href="http://www.panashindia.com/salwar"'>Salwar kameez online
Left by Alisha Patel on May 22, 2017 3:00 PM

# <a href="http://www.researchpapersforsale.org/">free essay help online</a>
Requesting Gravatar...
Do you wait until the last minute before undertaking tasks and assignments? Most people will procrastinate until they can wait no more and then rush to beat the deadline. When it comes to taxes, there are quite some pitfalls of taking this route.
free essay help online
Left by h b on May 27, 2017 12:28 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Really an awesome sharing..I truly love this post and looking forward to more similar posts.

Brand Designs
Website Designs
Left by Merkdavson on May 29, 2017 2:31 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Nice post. Thanks for sharing this useful information. Looking for web service then choose the best service - best web development company  .
Left by Nicole on May 29, 2017 6:35 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Hi creator! This gathering is impressive I truly like it; Total av antivirus 2017 particularly you have depicted everything in real focuses that is beneficial for us. Really I looked Buy custom Essays reason for finishing my post what will be submitted in the University.
Left by Manish Gupta on Jun 02, 2017 4:13 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This information can be very helpful for those people who are working in the programming section. When we are dealing with programs it is obvious that most of them deal with small errors that can cause problems to your website. [url=http://www.assignmentwriter.co.uk/]buy assignment service[/url]
Left by sab alex on Jun 07, 2017 2:45 PM

# Ms
Requesting Gravatar...
Now this is a very good thing. If you think about it closely, you will realize that the best things in life are usually not free and they often come at a very hefty cost. dissertation service This technical problem is the same. With the best people working for you, you need to understand the the best solution to any problem is the way it is structured
Left by Bethany Waytt on Jun 08, 2017 2:39 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
According to my read, you've got provided the simplest resolution to Retrieve taxonomic group objects of the sort from List exploitation LINQ and Generics. bulk sms marketing
Left by David joe on Jun 14, 2017 2:27 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Thank you for your work on the blog! You're doing a good job!
myhr.cvs.com
Left by panistefanin on Jul 01, 2017 12:02 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
After comprehending what the developer is required to do, the following area we have to mull over is the academic qualification. When all is said in done, a software engineer ought to have a degree qualification in software engineering, information technology or any related train. On the off chance that the software engineer is not a degree holder, you may investigate his or her working experience. Check with the candidate whether he or she knows about support of ASP Applications, web based business arrangement, online education services like Coursework Help UK and learning, long range interpersonal communication locales, corporate web applications, and so on.
Left by Jasmine Payne on Jul 06, 2017 7:05 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
What does one mean when one says that A is an object of X class? We mean that A has all the attributes of the X class, i.e., all the variables and methods of the class. Going by this definition when you create an object B of a subclass Y, B has all the methods and attributes of X in it. So we can say B is an object of Y as well. It can access everything from the Y. Except the private attributes of course. But that doesn't mean the object does not have it. It's probably an over-exacting argument but there you go. Do My Essays
Left by Jennifer Judy on Jul 12, 2017 3:45 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
It proved to be Very helpful to me and I am sure to all the commentators here!
see more
Left by Ann on Jul 25, 2017 9:41 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This is the first time I have come across this website and came to know about this LINQ and Generics that is used to retrieve subclass objects of type. Here it explained with some example and it is good to understand the readers very easily. Woodpeckers Toy Parts
Left by Danette on Jul 25, 2017 5:16 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Thank you for sharing this great tip. I also have a habit to use IList<T> but now I am going to try Enumerable so that I can retrieve the data more effectively. Buy Online Essay
Left by Bailey Shaw on Aug 08, 2017 11:11 AM

# Dubai Freezone Company Setup Cost
Requesting Gravatar...
This is really great work. Thank you for sharing such a good and useful information here in the blog for students. Dubai Freezone Company Setup Cost
Left by Dubai Freezone Company Setup Cos on Aug 12, 2017 11:39 AM

# GOOD
Requesting Gravatar...

This is a to a striking degree lighting up article. I in like path agree with your post title and your truly well light up your point of view. I am splendidly energetic to see this post. A dedication of gratefulness is all together for share with us. Keep it up and share the more most related post http://www.essayplus.co.uk/.

radiant work!
Left by Do My Essay from Me on Aug 16, 2017 12:11 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
The manner companies which includes LINQ to SQL paintings is generally thru the Queryable magnificence. At their center, they translate expression bushes into different query codecs, after which assemble suitable objects with the consequences of executing those out-of-system queries. UK Essay Writers
Left by Doyle Norman on Aug 16, 2017 3:38 PM

# Matlab Programming Assignment Help
Requesting Gravatar...
Thanx for sharing such useful post Matlab Programming Assignment Help keep it up :)
Left by Matlab Programming Assignment He on Aug 26, 2017 2:49 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
事情是非常开放和强烈清楚的解释问题。https://www.homeworkchina.com/ 是真正的信息。你的网站是非常有益的。
Left by 家庭作业帮助 on Aug 29, 2017 10:58 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Nice information, I am always like spend time on such a good post it gives me valuable information. If anybody need to read good article visit best thesis writing service
Left by GoldieRusnak on Aug 30, 2017 12:08 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
This is something really very amazing. Amazing information shared over here.

Nice work

the leather makers | affordable wordpress hosting
Left by Kathy on Sep 06, 2017 5:11 AM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
Do i have to make an extra file for this? I mean, will that work if i add this code in an external file and link it to the main program? marriage certificate attestation in dubai
Left by Alice on Sep 07, 2017 2:35 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...
My personal opinion is that programming is an easy job but students mistake during making a documentation we faced many issues regarding academic projects. In this case many students try to Essay Help UK
Left by Edward William on Sep 07, 2017 2:51 PM

# Civil Engineering Assignment Help Service
Requesting Gravatar...
It is a well-maintained site where people can learn about various topics. I am looking forward to read more blogs from here. Students finding it tough to write an assignment can try our online assignment help and can get their coursework written by assignment experts.
Left by Civil Engineering Assignment Hel on Sep 09, 2017 4:05 PM

# Civil Engineering Assignment Help Service
Requesting Gravatar...
I am certain this post has offered me some assistance with saving numerous hours of perusing other related presents just on find what I was searching for. Much obliged!
Left by Civil Engineering Assignment Hel on Sep 09, 2017 4:14 PM

# re: How to Retrieve subclass objects of type <T> from List <T> using LINQ and Generics
Requesting Gravatar...

I am a regular visitor to your website and have always liked the kind of work that you do. I genuinely get new ideas and thoughts that help me a lot in my personal work as well. The information that is provided on your web portal is amazing and I am always eager to catch hold of the new posts being published on your website. Doing that, I am always enlightened and it really seems to be a learning experience. keep up the good work and may your site prosper even more in the coming future with the addition of some more fabulous pieces of content.
terrarium tv apk
Left by terrarium tv on Sep 15, 2017 12:28 PM

Your comment:
 (will show your gravatar)


Copyright © Vamsidhar Mamillapalli | Powered by: GeeksWithBlogs.net