ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Add items to Generic List Collection in C#<p>Hi <a class="username" rel="yogesjoshi"> yogesjoshi</a>,</p> <p>Refer the below modified code.</p> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">public class Employee { public string Name { get; set; } public List&lt;EmployeeDepartments&gt; EmployeeDetails { get; set; } } public class EmployeeDepartments { public string Department { get; set; } public int Mark { get; set; } } protected void Form1_Load(object sender, EventArgs e) { List&lt;Employee&gt; employees = new List&lt;Employee&gt;(); List&lt;EmployeeDepartments&gt; depts = new List&lt;EmployeeDepartments&gt;(); try { Employee emp = new Employee(); emp.Name = &#34;a&#34;; EmployeeDepartments dept = new EmployeeDepartments(); dept.Department = &#34;IT&#34;; dept.Mark = 100; depts.Add(dept); emp.EmployeeDetails = depts; employees.Add(emp); } catch (Exception ex) { } }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/126920/Add-items-to-Generic-List-Collection-in-C/https://www.aspforums.net:443/Threads/126920/Add-items-to-Generic-List-Collection-in-C/Wed, 17 Oct 2018 00:04:34 GMT