Cannot inherit from static class
CodeRush Classic shows the Cannot inherit from static class code issue if a class inherits from a static class.
#Fix
Make the base class non static or make the current class not a descendant of the static class.
#Purpose
Highlights the class declaration statements, which would cause the Cannot derive from static class compilation error.
#Example
public static class MyClass
{
public static string Property1 { get; set; }
}
public class TestClass: MyClass
{
public TestClass(string str)
{
Property1 = str;
}
}
Fixes:
public class MyClass
{
public string Property1 { get; set; }
}
public class TestClass: MyClass
{
public TestClass(string str)
{
Property1 = str;
}
}
public static class MyClass
{
public static string Property1 { get; set; }
}
public class TestClass
{
public TestClass(string str)
{
Property1 = str;
}
public string Property1 { get; set; }
}