probably a really dumb question, but I keep getting the above error with the following code:
public interface IAttributeOption
{
AttributeTypeCode Type { get; set; }
}
You can probably tell, I'm trying to define an interface with a single property.
I know that somebody is BOUND to tell me "an interface is a virtual class, blah blah" and I want to confirm in advance I KNOW THIS! I'm clearly trying to define a property, which as far as I am aware is fine in an interface.
So what is wrong??
Thanks :)
An interface can't contain instance fields, instance constructors, or finalizers. Interface members are public by default, and you can explicitly specify accessibility modifiers, such as public , protected , internal , private , protected internal , or private protected .
Interface cannot contain fields because they represent a particular implementation of data. Multiple inheritance is possible with the help of Interfaces but not with classes.
An interface cannot contain instance fields. The only fields that can appear in an interface must be declared both static and final. An interface is not extended by a class; it is implemented by a class. An interface can extend multiple interfaces.
A Java interface is a bit like a Java class, except a Java interface can only contain method signatures and fields. A Java interface is not intended to contain implementations of the methods, only the signature (name, parameters and exceptions) of the method.
So what is wrong?
Nothing, your interface declaration is fine. Sounds like you possibly forgot to put your accessor declarations in previously:
public interface IAttributeOption
{
AttributeType Type; // no { get; set; }
}
If it's a linked assembly you may need to do a full rebuild as you may be pulling in a cached version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With