Answers for "how tdo i know if its a last iteration of foreach? c#"

C#
-1

c# for loop last iteration

// I want to find out the last iteration of a for loop in c#

for (var i=0; i<myList.Count; i++)
{
   if (i==myList.Count-1)
   {
      // this is the last item in the list
   }
}
Posted by: Guest on March-28-2021

Code answers related to "how tdo i know if its a last iteration of foreach? c#"

C# Answers by Framework

Browse Popular Code Answers by Language