Friday, January 9, 2015

Difference between Array and Arraylist

Arrays
Arrays are strongly typed collection of same datatype and these arrays are fixed length that cannot be changed during runtime. Generally in arrays we will store values with index basis that will start with zero. If we want to access values from arrays we need to pass index values.
Declaration of Arrays
Generally we will declare arrays with fixed length and store values like as shown below
string[] arr=new string[2];
arr[0] = "welcome";
arr[1] = "Aspdotnet-suresh";
In above code I declared array size 2 that means we can store only 2 string values in array.
Arraylists

Array lists are not strongly type collection. It will store values of different datatypes or same datatype. Array list size will increase or decrease dynamically it can take any size of values from any data type. These Array lists will be accessible with “System.Collections” namespace
Declaration of Arraylist
To know how to declare and store values in array lists check below code
ArrayList strarr = new ArrayList();
strarr.Add("welcome"); // Add string values
strarr.Add(10);   // Add integer values
strarr.Add(10.05); // Add float values
If you observe above code I haven’t mentioned any size in array list we can add all the required data there is no size limit and we will use add method to bind values to array list.
Difference between Array and ArrayList
Arrays
ArrayLists
These are strong type collection and allow to store fixed length
Array Lists are not strong type collection and size will increase or decrease dynamically
In arrays we can store only one datatype either int, string, char etc…
In arraylist we can store all the datatype values
Arrays belong to System.Array namespace
Arraylist belongs to System.Collection namespaces


http://www.aspdotnet-suresh.com/2013/09/difference-bw-array-and-arraylist-in-csharp-example.html 

Wednesday, January 7, 2015

What is the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe?

Why .Net does not support multiple inheritance?


Let me tell you a scenario.

I have a class Shape1

It has CalcualteArea method
Class Shape1
{
     public void CalculateArea()
     {
       //
     }
}

There is another class shape2 that one also has same method 
Class Shape2
{
     public void CalculateArea()
     {
       //
     }
}

Now i have a child class Circle, it derives from both SHape1 and shape2;

public class Circle: Shape1,shape2
{
}

Now when i create object for Circle, and call the method, system doesn't know which calculate area method to be called.. Both has same signatures. So compiler will get confuse .that's why multiple inheritances are not allowed.

But there can be multiple interfaces because interfaces dont ve methjod definition..Even both the interfaces have same method, both of them dont ve any implementation and always method in the child class will be executed..

------------------------------------------------------
To understand that you need to understand the Diamond problem first:

The Diamond problem is an ambiguity that arises when two classes B and C inherit from Class A and class D inherits from both B and C. If a method in D calls a method defined in A(and does not override the method), and B and C have overridden that method differently, then from which class does it inherit: B or C?

That is the reason why C# and Java languages does not support multiple inheritance.

A diamond class inheritance diagram.



The "diamond problem" (sometimes referred to as the "deadly diamond of death"[5]) is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and/or C has overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C?
For example, in the context of GUI software development, a class Button may inherit from both classes Rectangle (for appearance) and Clickable (for functionality/input handling), and classes Rectangle and Clickable both inherit from the Object class. Now if the equals method is called for a Button object and there is no such method in the Button class but there is an overridden equals method in Rectangle or Clickable (or both), which method should be eventually called?
It is called the "diamond problem" because of the shape of the class inheritance diagram in this situation. In this case, class A is at the top, both B and C separately beneath it, and D joins the two together at the bottom to form a diamond shape

http://en.wikipedia.org/wiki/Diamond_problem#The_diamond_problem
http://www.artima.com/intv/dotnetP.html 

http://blogs.msdn.com/b/csharpfaq/archive/2004/03/07/85562.aspx