C#

C#

Made by DeepSource

Accessor like method has return type void CS-R1013

Anti-pattern
Major

Accessor-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.

Bad Practice

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.
}

Recommended

public int GetNthPrime(int n)
{
    // Method refactored to return the calculated result.
}