Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to create a list of list of different classes?
marcelo presto
Oct 15 2017 4:38 PM
169
Reply
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?
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
interface implementation with another interface
Looping Trouble