CodeRush Classic shows the Cannot create an instance of interface code issue if an instance creation statement references an interface.
Fix
Create an instance of a class implementing the current interface.
Purpose
Highlights the instance creation statements, which would cause the Cannot create an instance of the abstract class or interface compilation error.
Example
interface IMyClass
{
void OutputText(string text);
}
public class TestClass
{
public TestClass()
{
IMyClass objVar = new │IMyClass();
}
}
Fix:
interface IMyClass
{
void OutputText(string text);
}
class MyClass: IMyClass
{
public override void OutputText(string text)
{
Console.Write(text);
}
}
public class TestClass
{
public TestClass()
{
IMyClass objVar = new MyClass();
}
}
We are updating the DevExpress product documentation website and this page is part of our new experience. During this transition period, product documentation remains available in our previous format at documentation.devexpress.com. Learn More...