O'Reilly Forums: Interface Question - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Interface Question p275 2nd Edition

#1 User is offline   wunderwaffe 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 26
  • Joined: 14-January 14

Posted 25 February 2014 - 03:52 AM

Hello,

When I follow the instructions on this page, I still get errors, namely:

xxx cannot implement an interface member because it is not public

I thought the default value of methods and attributes was public? I set them as public and it removed the error.

'Bee.AlertLevel.get' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors

Adding the set accessor to Bee.cs fixes this but is there a reason why this isn't in the book? (p.273 only has "get" accessor for AlertLevel)
0

#2 User is offline   AndrewStellman 

  • Andrew Stellman
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 806
  • Joined: 08-October 08
  • Gender:Male
  • Location:Brooklyn, NY
  • Interests:Author of: "Head First C#", "Beautiful Teams", "Head First PMP", "Applied Software Project Management"

Posted 25 February 2014 - 01:29 PM

If you leave off the access modifier, the member defaults to internal, not public. There's an explanation of this on page 315 (in the third edition).

And if there's only a get accessor specified in the interface, the property that implements it can either only have a public get accessory, a public get and private or internal set accessor, or public get and set.



Andrew Stellman
Author, Head First C#
Building Better Software -- http://www.stellman-greene.com
0

#3 User is offline   wunderwaffe 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 26
  • Joined: 14-January 14

Posted 26 February 2014 - 01:44 AM

View PostAndrewStellman, on 25 February 2014 - 01:29 PM, said:

If you leave off the access modifier, the member defaults to internal, not public. There's an explanation of this on page 315 (in the third edition).

And if there's only a get accessor specified in the interface, the property that implements it can either only have a public get accessory, a public get and private or internal set accessor, or public get and set.


Cheers Andrew.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users