個人的には、そのメソッド名ではどちらも行いません。
代わりに、次の 2 つの方法を作成します。
TryFindSpecificRow
FindSpecificRow
これは Int32.Parse/TryParse のパターンに従い、C# では次のようになります。
public static Boolean TryFindSpecificRow(DataTable table, out Int32 rowNumber)
{
if (row-can-be-found)
{
rowNumber = index-of-row-that-was-found;
return true;
}
else
{
rowNumber = 0; // this value will not be used anyway
return false;
}
}
public static Int32 FindSpecificRow(DataTable table)
{
Int32 rowNumber;
if (TryFindSpecificRow(table, out rowNumber))
return rowNumber;
else
throw new RowNotFoundException(String.Format("Row {0} was not found", rowNumber));
}
編集:質問により適切になるように変更されました。