Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have a community question for you, I have an if-else condition in c#, I would like to get back from counting else so that the loop can continue. Does anyone know how? What it should look like is shown in the code...

Thank you very much for any advice.

Have a nice day.

What I have tried:

while (pointCursor.MoveNext())
               {
                   pointCounter++;
                   if (pointCounter>1)
                   {
                       var pointFeature = pointCursor.Current as Feature;
                       if (pointFeature == null) continue;
                       Polyline polyline = pointFeature.GetShape() as Polyline;
                       ReadOnlyPointCollection pts = polyline.Points;
                       int numPts = polyline.PointCount;
                       List<MapPoint> lineMapPoints = new List<MapPoint> { pts[0], pts[numPts - 1] };
                       // add the feature point geometry as a coordinate into the vertex list of the line
                       // - ensure that the projection of the point geometry is converted to match the spatial reference of the line

                       var newPolyline = PolylineBuilder.CreatePolyline(lineMapPoints, polylineDefinition.GetSpatialReference());
                       // queue the create operation as part of the edit operation
                       createOperation.Create(polylineLayer, newPolyline);
                   }
                   else
                   {
                      return;//from there I would like to go back to pointCounter ++
                   }

               }
Posted
Updated 3-Oct-21 20:40pm

1 solution

Simple: don't use the keyword return.
return means "immediate exit this method, without executing any further statements in it (unless they are part of a finally block associated with an active try block)"

Remove the else block completely, and the loop will just continue to the end.
 
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