代码检查:类无法实例化
此检查会报告无法实例化的类。 这通常意味着该类只有私有构造函数,并且没有创建实例的路径。 此类通常用于静态工具类,或缺少调用方需要的构造函数。
示例
public sealed class StringUtil
{
private StringUtil() { }
public static string CustomSplit(string s, char c)
{
return s;
}
}
public static class StringUtil
{
public static string CustomSplit(string s, char c)
{
return s;
}
}
快速修复
此检查会提供修复建议,例如将该类转换为 static 类,或在设计需要时生成构造函数。
2026年 5月 8日