I have a base class Posts
and Notifications
, Notes
and Photos
inherit from Posts
. How can I a single list with all inherited objects from Posts in a single List<Post>
.
var notes = posts.OfType<Note>();
var photos = posts.OfType<Photo>();
var notifications = posts.OfType<Notification>(); ;
return (from n in notes
select new Stream()
{
id = n.post_id,
value = n.value,
timestamp = n.timestamp,
type = "note"
}).ToList();
The above of course returns notes only.
Thanks in advance.