ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data Namespace / RowCursor Class / MoveNext Method
Example

In This Topic
    MoveNext Method (RowCursor)
    In This Topic
    Advances to the next Row in this RowCursor. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public bool MoveNext()
    Public Function MoveNext() As Boolean

    Return Value

    true if the cursor has successfully advanced to the next row; false if the cursor has passed the end of the collection.
    Exceptions
    ExceptionDescription
    A geodatabase-related exception has occurred.
    Remarks
    The RowCursor can only advance sequentially forward. To move the cursor back to the beginning, you will have to reexecute the search to obtain a new row cursor. If MoveNext() returns true, a Row object is created. Even if this row (Current) is not otherwise needed, it should be properly disposed through a call to System.IDisposable.Dispose or with the use of a using statement.
    Example
    Searching a Table using QueryFilter
    public async Task SearchingATable()
    {
      try
      {
        await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
        {
          using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
          using (Table table = geodatabase.OpenDataset<Table>("EmployeeInfo"))
          {
    
            QueryFilter queryFilter = new QueryFilter
            {
              WhereClause = "COSTCTRN = 'Information Technology'",
              SubFields = "KNOWNAS, OFFICE, LOCATION",
              PostfixClause = "ORDER BY OFFICE"
            };
    
            using (RowCursor rowCursor = table.Search(queryFilter, false))
            {
              while (rowCursor.MoveNext())
              {
                using (Row row = rowCursor.Current)
                {
                  string location = Convert.ToString(row["LOCATION"]);
                  string knownAs = Convert.ToString(row["KNOWNAS"]);
                }
              }
            }
          }
        });
      }
      catch (GeodatabaseFieldException fieldException)
      {
        // One of the fields in the where clause might not exist. There are multiple ways this can be handled:
        // Handle error appropriately
      }
      catch (Exception exception)
      {
        // logger.Error(exception.Message);
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also