Nested List in C#
Consider there are two Class
public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public List< Addresses > { get; set; }
}
public class Address
{
public string Line1 { get; set; }
public string Line2 { get; set; }
public string ZipCode { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
}
Procedure used to add multiple class in the List
var personDetails = new List< Person >
{
new Person
{
Id = 1, FirstName = "Arun",
LastName = "Prakash",
Addresses = new List< Address >
{
new Address{Line1 = "Hope College",Line2 = "Coimbatore"}
}
},
new Person{
Id = 2, FirstName = "Sanjay",
LastName = "Ramasamy",
Addresses = new List< Address >
{
new Address{Line1 = "Anna Salai",Line2= "Chennai"}
}
}
};
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
Showing posts with label Nested List in C#. Show all posts
Showing posts with label Nested List in C#. Show all posts
12 August 2013
Subscribe to:
Posts (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...