can someone tell me the difference???
5 replies to this topic
#1
Posted 08 October 2011 - 03:03 PM
|
|
|
#2
Posted 08 October 2011 - 04:31 PM
I cant tell for every single language, but for the one I know, class have code, interface don't.
Interface is a contract. If someone use your interface, they need to create the function that the interface tell them to create.
Class have function and code.
So a class can be on it own, but a interface without any class is nothing.
I use interface mostly when I work on big project with other people and want to be certain that they will implements certains function on all their class. Since a class that don't implemente everything will fail to compile.
Interface is a contract. If someone use your interface, they need to create the function that the interface tell them to create.
Class have function and code.
So a class can be on it own, but a interface without any class is nothing.
I use interface mostly when I work on big project with other people and want to be certain that they will implements certains function on all their class. Since a class that don't implemente everything will fail to compile.
#3
Posted 08 October 2011 - 06:37 PM
For C#, you cannot instantiate an interface. They don't have member variables, and they don't implement methods. Interfaces define methods that a class which implements the interface must define.
#4
Posted 09 October 2011 - 11:01 AM
some example please
#5
Posted 09 October 2011 - 07:14 PM
Do you have a book on C#? It should have numerous examples in it.
#6
Posted 21 October 2011 - 06:25 PM
A C# Class Considered being the primary building block of the language. What I mean by the primary building block of the language is that every time you work with C# you will create Classes to form a program. We use Classes as a template to put the properties and functionalities or behaviors in one building block for some group of objects and after that we use that template to create the objects we need.
A class can contain declarations of the following members:
Constructors, Destructors, Constants, Fields, Methods, Properties,Indexers, Operators, Events, Delegates, Classes, Interfaces, Structs
An interface contains only the signatures of methods, delegates or events. The implementation of the methods is done in the class that implements the interface. A class that implements an interface can explicitly implement members of that interface. An explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface.
An interface can inherit from one or more base interfaces. When a base type list contains a base class and interfaces, the base class must come first in the list.
A class can contain declarations of the following members:
Constructors, Destructors, Constants, Fields, Methods, Properties,Indexers, Operators, Events, Delegates, Classes, Interfaces, Structs
An interface contains only the signatures of methods, delegates or events. The implementation of the methods is done in the class that implements the interface. A class that implements an interface can explicitly implement members of that interface. An explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface.
An interface can inherit from one or more base interfaces. When a base type list contains a base class and interfaces, the base class must come first in the list.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









