Posts

Showing posts from 2021

difference between array and array list in c#

1.The capacity of an  Array   is fixed.  Where as,  ArrayList   can increase and decrease size dynamically.   2.An  Array   is a collection of similar items.  Where as,  ArrayList   can hold item of different types.   3.Array is in the System namespace.  Where as, ArrayList is in the System.Collections namespace.   4.An  Array   can have multiple dimensions.  Where as,  ArrayList   always has exactly one dimension.   We can set the lower bound of an  Array .  Where as, the lower bound of an  ArrayList   is always zero.     Array   is faster and that is because  ArrayList   uses a fixed amount of array.  However when you add an element to the  ArrayList   and it overflows. It creates a new  Array   and copies every element from the old one to the new one.  You will only feel this if you add to often.

difference between var and dynamic c#

  Programming languages can normally be considered to be either statically typed or dynamically typed. A static (not to be confused with the static keyword, used for classes) typed language validates the syntax or checks for any errors during the compilation of the code. On the other hand, dynamically typed languages validate the syntax or checks for errors only at run time. For example, C# and Java are a static type and JavaScript is a dynamically typed language. C# was previously considered to be a statically typed language, since all the code written was validated at the compile time itself. But, with the introduction of the dynamic keyword in C# 4.0, it became a dynamic typed language also. The two concepts of static and dynamic types in C# can be illustrated with the use of the two keywords named var and dynamic. Let's discuss some basic differences between these two, based on some of their characteristics. When were they introduced var was int

abstract class and interface difference c#

Abstract Class & interfaces Q:In what scenarios will you use a abstract class and in what scenarios will you use a interface? •      If you want to increase reusability in inheritance then abstract classes are good.  •      If you want implement or force some methods across classes must be for uniformity you can use a interface. •      So to increase reusability via inheritance use abstract class as it is nothing but a base class and to force methods use interfaces. Some points about an Abstract Class are: 1.      We cannot create an object of an Abstract Class. 2.      An Abstract Class can be inherited with its derived class. 3.      Can have both concrete and abstract methods but at least one abstract method is compulsory in an Abstract Class. 4.      An Abstract Class is used as a base class for projects. 5.      An Abstract Class can inherit another base class and base interfaces. 6.      The constructor of an Abstract Class can be called through the derived class