1
public int FirstRecord
{
    get
    {
        if (NumRecords < 1)
            throw new Exception("No records available");

        return PageNumber * PageSize;
    }
}

In static code analysis it is showing the below warning.

FirstRecord.get() creates an exception of type 'Exception', an exception type that should not be raised in a property. If this exception instance might be raised, use a different exception type, convert this property into a method, or change this property's logic so that it no longer raises an exception.

Ravali
  • 23
  • 3
  • 1
    Where is `NumRecords` set? Can you trigger the exception there? [Here's a question about exceptions in properties.](https://stackoverflow.com/questions/1488472/best-practices-throwing-exceptions-from-properties) – ProgrammingLlama Jun 19 '19 at 04:35
  • 1
    Possible duplicate of [Best practices: throwing exceptions from properties](https://stackoverflow.com/questions/1488472/best-practices-throwing-exceptions-from-properties) – madoxdev Jun 19 '19 at 06:30

0 Answers0