我有这个方法,我想返回一个我将在另一个方法中使用的字符串,但是当我将 return 语句放在 for 循环中时,该方法仍然要求返回。我怎样才能正确地构造它,以便我可以返回我想要的字符串。
public string ReadDocument(string fileName)
{
try
{
theImage = codecs.Load(Enhance(fileName), 0, CodecsLoadByteOrder.BgrOrGray, 1, -1);
for (int num = 1; num <= theImage.PageCount; num++)
{
BarcodeData dataArray = engine.Reader.ReadBarcode(theImage, LogicalRectangle.Empty, 0, null);
qrCode = dataArray.Value;
if (theImage.Page < theImage.PageCount)
theImage.Page++;
return dataArray.Value;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}