Jump to content
  • Advertisement
Sign in to follow this  
kitman20022002

Why properties can inherit from interface

This topic is 931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
You can't create fields in interfaces. You can create properties in an interface, you just can't implement them on an interface. Remember, under the hood, a property named "Foo" turns into two methods with names like "get_Foo" and "set_Foo," so declaring a property on an interface is like adding those methods to that interface. Edited by Oberon_Command

Share this post


Link to post
Share on other sites

An interface is not a class, it has no implementation and you cant instantiate them directly. They are just a "specification" of the properties and methods that MUST be implemented by a class that implements the interface.  

 

In fact there are two different ways that a class can implement the properties and methods on an interface, implicit and explicit, and neither of them involve inheritance as there is nothing to inherit from. Classes can inherit from only one other class but a class can implement many interfaces both are very different relationships smile.png

 

This is the second time you have referenced careerride and I have to say I am not impressed with the site or the quality of questions/answer they have. I would say find a good book on C# and read that and work through things in Visual Studio (Which is free), the Wrox books are normmaly very solid on facts and teaching

Edited by WozNZ

Share this post


Link to post
Share on other sites

An interface is not a class, it has no implementation and you cant instantiate them directly. They are just a "specification" of the properties and methods that MUST be implemented by a class that implements the interface.  

 

In fact there are two different ways that a class can implement the properties and methods on an interface, implicit and explicit, and neither of them involve inheritance as there is nothing to inherit from. Classes can inherit from only one other class but a class can implement many interfaces both are very different relationships smile.png

 

This is the second time you have referenced careerride and I have to say I am not impressed with the site or the quality of questions/answer they have. I would say find a good book on C# and read that and work through things in Visual Studio (Which is free), the Wrox books are normmaly very solid on facts and teaching

 I know careerride.com is bad, but I was even surprised because actually one of the company that I interviewed was using this as a test.   

Edited by kitman20022002

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!