void
CS-R1013Accessor-like methods are methods that usually return something and begin with keywords such as get
. Having such methods have return type void
is an antipattern and can affect the code readability. It is therefore recommended that you refactor your code accordingly.
public void GetNthPrime(int n)
{
// This method sets a class field rather than returning
// the result. Either the method should be renamed accordingly,
// or should directly return the result.
}
public int GetNthPrime(int n)
{
// Method refactored to return the calculated result.
}