Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Interfaces cannot contain instance fields
An interface can contain methods, properties, and fields.
The following sample generates CS0525:
// CS0525.cs
namespace x
{
public interface clx
{
public int i; // CS0525
}
}
Only classes can contain instance data. Interfaces describe a contract. These articles help you learn their key differences and use cases.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.