Can this be replaced with ForEach or IEnumrable
IAFormApp formApp = new AFormAppClass();
IFields myFields = (IFields)formApp.Fields;
IEnumerator myEnumerator = myFields.GetEnumerator();
while (myEnumerator.MoveNext())
{
IField myField = (IField)myEnumerator.Current;
}
myEnumerator.MoveNext() is not iterating sequentially through my PDF Fields.
I am not familiar with the Adobe SDK API. But I think you are closer than you think. It seems that
IFieldsis derived fromIEnumerableorIEnumerable<IField>.In C#, you can use foreach to iterate through a collection.
For example:
In the background,
foreachusesIEnumerable.GetEnumerator()or the genericIEnumerable<T>.GetEnumerator()to iterate over the elements in the collection. The mentioned methodGetEnumerator()returns anIEnumeratorrespectivelyIEnumerator<T>.You need to check where
IFieldsis derived from. If it is derived fromIEnumerable<IField>, you can use the example above. If it derives fromIEnumerable, you need to convert the object to the desired object type, becauseIEnumerator.Currentreturns an object.For more information on using
IEnumerableor the generic formIEnumerable<T>, see the C# Programming Guide.