Fahad Azeez

Fahad Azeez

  • 2k
  • 4
  • 1.4k

Nested foreach loop using Linq

Oct 1 2019 7:02 AM

Hi,

I have a list of object as following:

  1. List Sample(){  
  2. {Id =1 , ProjectCode=”1801”, ProjectName =” Commercial “, Year=”2018”},  
  3. {Id =2 , ProjectCode=”1802”, ProjectName =” Law “, Year=”2018”},  
  4. {Id =3 , ProjectCode=”1803”, ProjectName =” Action “, Year=”2018”},  
  5. {Id =4 , ProjectCode=”1901”, ProjectName =” Commercial “, Year=”2019”},  
  6. {Id =5 , ProjectCode=”2001”, ProjectName =” Commercial “, Year=”2020”}  

I want to produce the following kind of result. How I can do that using ‘foreach nested loop using linq?.

 

·         2018

o   1801 – Commercial

§  In

§  Out

o   1802 – Law

§  In

§  Out

o   1803 – Action

§  In

§  Out

o    

·         2019

o   1901 – Commercial

§  In

§  Out

·         2020

o   2001 – Commercial

§  In

§  Out

 

Thanks in advance.


Answers (1)