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)
Consistency level in Azure cosmos db
Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
· Azure Service Fabric is Microsoft’s Platform-as-a-Service (PaaS) and is used to build and deploy microservices-based cloud applicat...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...