Ans: Class and Struct are both user-defined data types but have certain important distinctions:
Ans: Collection of garbage is the process of clearing the memory collected by undesirable things. When a class object is created, the object in the heap memory will automatically have a certain memory space. After all the operations are performed on the item, the object's memory space becomes a waste. Memory needs to be free. In three instances, garbage collecting occurs:
Ans: Extension methods allow you to add methods to existing types without creating, compiling, or other changes to the original type. An extension method is a particular static method, yet it is called as if an extension method were instance methods.
An extension's static method is a class method that uses the "this" modifier for the first parameter. The first parameter type is the extended parameter type. Extension methods are only available if the namespace is explicitly imported using a directive into your source code.
Ans: You always know C is the language of the proceeding, whereas C# is a more objective language. The major distinction is that C# automatically supports Common Language Runtime (CLR) garbage collection, while C does not. C# mostly needs a .NET framework to run, whereas C is a language for platform diagnostics.
Ans: Let's examine the distinctions between an abstract and an interface class:
Abstract classes are not instantiable classes, i.e., cannot build an object. The interface is like an abstract class because abstract methods are contained within the interface.
Surprisingly, abstract and non-abstract methods can be used in abstract classes, although all interface methods are abstract.
Since abstract classes might have abstract and non-abstract methods, we must use the keyword Abstract to specify abstract methods. There's no such necessity on the interface, however.
An abstract class has constructors, while an interface encompasses none.
|