Hi Team, Is there any option to get last index of in foreach loop in linq?
@manojdesai272 You can use <<[items.First()]>>
and <<[items.Last()]>>
to get the first or the last items in the list. For example see the following systax:
<<foreach [item in items]>>
The first item in the collection: <<[items.First()]>>
The current item is: <<[item]>>
The last item in the collection: <<[items.Last()]>>
<</foreach>>
Here is the test code:
List<string> dymmyData = new List<string>() { "First Item", "Second Item", "Third Item", "Fourth Item" };
Document doc = new Document(@"C:\Temp\in.docx");
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, dymmyData, "items");
doc.Save(@"C:\Temp\out.docx");