I am not sure why I keep getting the conversion error that states, "Cannot convert from 'System.Threading.Task.Task<string> to string" when I tried to return a list of string values as a argument parameter for another method. Please see my script below:
//Looking up a list of string values, mukeys
public async Task<List<string>> LookupMukey()
{
var mukeys = new List<string>();
var MV = MapView.Active;
int mukeyCount = 0;
var SelectionLayer = MV.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(fl => fl.Name.Contains("SelectionLayer")).FirstOrDefault();
await QueuedTask.Run(() =>
{
using (var SelectionTable = SelectionLayer.GetTable())
{
using (var rowCursor = SelectionTable.Search())
{
while (rowCursor.MoveNext())
{
using (Row row = rowCursor.Current)
{
var mukey = Convert.ToString(row["mukey"]);
mukeys.Add(mukey);
mukeyCount++;
}
}
}
}
});
return mukeys;
}
//calling the list of mukeys and outputting the values into a text file (performed by the function, //OutputTextFiles() )
Utilities helperclass = new Utilities();
var strOutput = helperclass.LookupMukey();
helperclass.OutputTextFiles(strOutput, "TestFile"); //error occurs at strOutput
Thanks for your help!