| C# Question Answers-61 - 70 | C# Question Answers-81 - 90 | |
C# (C-Sharp) Question Answers - 71-80 |
Covariance: Substitute a derived type where a base type is expected. Contravariance: Substitute a base type where a derived type is expected. Supported only for reference types.
Data abstraction is a simplified view of an object showing only essential features and hiding unnecessary details. In OOP, implemented as a class or abstract data type.
KeyNotFoundException for missing keys; Hashtable returns null.Occurs when using virtual in base class and override in derived class.
Encapsulation is the mechanism of bundling code and data into a single unit and protecting it from external interference. Implemented using classes in C#.
Explicit: Implement interface members with interface name. Implicit: Implement interface members without interface name. Use implicit normally; use explicit when implementing multiple interfaces with conflicting method signatures.
An extension method is a static method of a static class that can be invoked like as an instance method syntax. Extension methods are used to add new "Behaviors" to an existing type without altering.
In extension method this keyword is used with the first parameter and the first parameter will be of type that is extended by extension method. Other parameters of extensions types can be of any types (data type).
A static method of a static class that can be called as if it were an instance method.
public static class MyExtensions {
public static int Square(this int n) { return n * n; }
}
int m = 5;
Console.WriteLine("{0} is square of {1}", m.Square(), m);
// Output: 25 is square of 5
Gen-2 collection is called Full Garbage Collection. It collects all objects from Gen-0, Gen-1, and Gen-2.
Full Trust allows code to have all permissions. GAC’ed assemblies have Full Trust by default due to being on the local system with a strong name.
Global Assembly Cache Tool (gacutil.exe) allows installing, removing, and listing assemblies in the GAC.
| C# Question Answers-61 - 70 | C# Question Answers-81 - 90 | |