Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get List if a want to pass number 3 value directly in the list

What I have tried:

C#
foreach (var item in Model.material.dynamicFieldInfo.DynamicFields_List.toList(k))
{

}
Posted
Updated 8-Apr-22 5:17am
v2

1 solution

If you mean you only want item 3, then then don't use a loop at all:
C#
var third = Model.dynamicFieldInfo.DynamicFields_List[2];

Otherwise, use a counter outside the loop:
C#
int count = 0;
foreach (var item in Model.dynamicFieldInfo.DynamicFields_List)
   {
   if (++count == 3)
       {
       ... do something with it ...
       count = 0
       }
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900