I would like to force a set of classes to define three fields (of type string).
In an abstract class, I get that fields cannot be abstract and in an interface, I get an error saying that an interface cannot contain a field.
Is there no way to do this or am I not understanding this correctly? I’d rather not use methods because for some weird reason, the parentheses annoy me.
I would like to force a set of classes to define three fields (of
Share
Like everyone else says, use properties instead of fields, but you can do something like I interpreted in the comments as follows for read-only members:
If you want the fields to be modifiable later, you’ll have to either use automatic properties or declare concrete backing fields and getter/setter pairs for each property.