Some points to remeber about abstact class and interface
Interface:-
1. An interface can inherits from muiltiple interfaces.
2. An interface contains only the signatures of methods, delegates, events, indexers or propeties.
3. We can't give explicit access modifier of any of the members of interface by default all the members of interface are public.
4. if a class implements an interface it has to implement all the methods which are defined in interface.
5. An interface can be a member of a namespace or a class.
6. if you don't know the implementation of any of the method of you type you should use interface.
7. When a base type list contains a base class and interfaces, the base class must come first in the list.
Abstract Class
1. A Abstract Class Can't be a sealed class becaue it ment to be an base class if you try to make it sealed it will give Compile time error.
2. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.
3. An abstract class cannot be instantiated.
4. An abstract class may contain abstract methods and accessors and concrete methods.
5. An abstract class can have all the concrete methods.
6. if a method is marked as abstract then we have to make its class as abstract class.
7. its possbile to make an abstract class by inheriting an other abstract class
Abstract Keywords
1. The abstract modifier can be used with classes, methods, properties, indexers, and events.
2. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes.
3. Use the abstract modifier in a method or property declaration to indicate that the method or property does not contain implementation.
4. An abstract class cannot be instantiated.
5. An abstract class may contain abstract methods and accessors.
6. It is not possible to modify an abstract class with the sealed modifier, which means that the class cannot be inherited.
7. A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
8. An abstract method is implicitly a virtual method.
9. Abstract method declarations are only permitted in abstract classes.
10. Because an abstract method declaration provides no actual implementation, there is no method body; the method declaration simply ends with a semicolon and there are no braces ({ }) following the signature. For example: public abstract void MyMethod();
11. The implementation is provided by an overriding method, which is a member of a non-abstract class.
12. It is an error to use the static or virtual modifiers in an abstract method declaration.
13. Abstract properties behave like abstract methods, except for the differences in declaration and invocation syntax.
14. It is an error to use the abstract modifier on a static property.
15. An abstract inherited property can be overridden in a derived class by including a property declaration that uses the override modifier.
16. An abstract class must provide implementation for all interface members.
17. An abstract class that implements an interface might map the interface methods onto abstract methods. For example:
interface I
{
void M();
}
abstract class C: I
{
public abstract void M();
}
0 comments:
Post a Comment