If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

looking for exercises to practice interfaces on c#

i`m new at c# and i have learned about the interfaces subject so i am looking for a little project that i can do , that i will need to use interface , so i will understand this subject better
if some one have a pdf from scool or uni with exercises i`ll be happy to get it

Re: looking for exercises to practice interfaces on c#

Re: looking for exercises to practice interfaces on c#

In general if you are wanting to understand interfaces. I say just get in there spin up a simple console application and give it a try.

An interface is nothing more than a contract between it and its implementer. So basically the interface is saying "hey you implementer, you have to have this method, field, etc...I don't care what you do with it but you have to have it."

so you can see that iTest is of type IMyInterface but since both classes implement IMyInterface we can use the same variable when declaring a new instance of each class. But they return different values when calling the same method.

Re: looking for exercises to practice interfaces on c#

To understand interfaces you first need to have at least some idea of the concept of type abstraction (generalisation), type derivation and specialization, and inheritance in object-oriented programming (both interface inheritance and implementation inheritance). Knowing a bit about composition doesn't hurt as well. Are you familiar with any of these things? If not, start by learning what classes and objects are, and how they interact together, and worry about interfaces later. Interfaces are all about making this interaction possible, maintainable, and flexible.

Re: looking for exercises to practice interfaces on c#

You should be able to develop a console based (or text style) game using interfaces as well, as long as you take on a good OO model for the design. You can write a strictly procedural game as well, so it's for the most part awareness of what you're doing with your objects that would make the difference. Inheritance from base classes, and interfaces for perhaps how each enemy interacts or behaves would be a good setup.