تخطَّ إلى المحتوى

Make class static (ARCH711)

هذا المحتوى غير متوفر بلغتك بعد.

Key dotnet.codequality.make-class-static · Severity info · Category codequality

A class that holds only static members is meaningless to instantiate. Making the class static prevents misuse at compile time.

public class MathHelper
{
public static int Square(int x) => x * x;
}
public static class MathHelper
{
public static int Square(int x) => x * x;
}

Add the static modifier to a class that contains only static members.