1. This is my Code
foreach (var detail in payment.PaymentDetails)
{
PAYMENT_DETAILS pdetail = new PAYMENT_DETAILS()
{
DETAILS_NO = detail.Order,
ACCOUNT_CODE = detail.AccountCode,
AMOUNT = detail.Payment,
PARTICULARS = detail.Particulars,
SUBACCOUNT_CODE = detail.SubAccountCode,
SUBACCOUNT_TYPE = detail.SubAccountType,
USER_ID = User.Identity.Name,
T1 = detail.T1,
T5 = detail.T5,
GPN_FLAG = detail.GPN_Flag,
LAST_UPDATE = DateTime.Now,
EMPLOYEE_NO = detail.EmployeeNo
};
paymentHeader.PAYMENT_DETAILS.Add(pdetail);
}
2. i wanted to add foreach (var detail in payment.PaymentDetails + 4)
3. if possible can i add 4 count?
Plase help me

Mayooran NavamanyPosted Jul 14, 2023, 4:02 PM
Hi Rolando
One way to get the count of the elements while using a
foreachloop is to declare a variable to keep track of the count and increment it on each iteration. Here's a link with example I think it's helpful for youhttps://shahedbd.medium.com/counter-in-foreach-loop-using-c-840934ce117d