Posts

Showing posts with the label override

Modifiers in C#

Here are the modifiers with description and where they are applies: Modifier Applies To Description New Function Members The member hides an inherited member with the same signature. Static All members The member does not operate on a specific instance of the class. Virtual Classes and Function members only The members can be overridden by a derived class. Abstract Function members only A virtual member that defines the signature of the members, but doesn’t provide an implementation. Override Function members only Members override inherited virtual or abstract members. Sealed Classes Members override an inherited virtual member, but cannot be overridden by any classes that inherit from this class. Must be used in conjunction with override. Extern Static[dll Import] method...

Difference between Shadow and Override

Most of the time these question(difference's) are asked in interview's. That's why i thought to discuss this with you people. Shadowing: - This is a VB.Net Concept by which you can provide a new implementation for the base class member without overriding the member. You can shadow a base class member in the derived class by using the keyword "Shadows". The method signature , access level and return type of the shadowed member can be completely different than the base class member. Hiding: - This is a C# Concept by which you can provide a new implementation for the base class member without overriding the member. You can hide a base class member in the derived class by using the keyword "new". The method signature, access level and return type of the hidden member has to be same as the base class member. Comparing the three:- The access level, signature and the return type can only be changed when you are shadowing with VB.NET. Hiding a...