TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
marcelo presto
NA
7
1.3k
How to create a list of list of different classes?
Oct 15 2017 4:38 PM
Hello friends!
I'm newbie in c# and I have in my project two classes: User and Entity. I want to create a List of List of these classes. Bellow what i tried.
List<User> lu =newList<User>();List<Entity> le =newList<Entity>();
User a =newUser();
User b =newUser();
User c =newUser();
User d =newUser();
Entity w =newEntity();
Entity x =newEntity();
Entity y =newEntity();
Entity z =newEntity();
lu.Add(a);
lu.Add(b);
lu.Add(c);
lu.Add(d);
le.Add(w);
le.Add(x);
le.Add(y);
le.Add(z);
//This part dont work!
List<List<dynamic>> l =newList<List<dynamic>>();
l.Add(lu);l.Add(le);
To show this list:
foreach(var p inViewBag.usrs)
{
<tr>
<td>@p.Name</td>
<td>@p.LasName</td>
</tr>
}
How can i do that? Create and show a List of List of different objects?
Reply
Answers (
1
)
interface implementation with another interface
Looping Trouble