C#

C#

Made by DeepSource

ToString method should never return null CS-R1011

Anti-pattern
Critical

The ToString method should return a string that best represents your class/object. Returning null from such a method does not make any sense and is therefore recommended that you refactor this method to return a more suitable and appropriate representation.

Bad Practice

class Point
{
    public override string ToString()
    {
        return null;
    }
}

Recommended

class Point
{
    public override string ToString()
    {
        return $"({x}, {y})";
    }
}

Reference