Does .net CLR typecast the objects to the ones mentioned in the collection declaration? If i declare a
List<string> lststrs= new List<string>();
lststrs.add("ssdfsf");
does .net typecasts this object while adding and retriving?????
Well i think the question itself was not clearly understood by everyone.Let me elaborate. In java there is generics ,but if you decompile the code you will notice that ,the compiler places a typecast everywhere the Collection object is used. For Ex: List listOfStrings; listOfStrings.add(""); String value = listOfStrings.get(1); After decompiling the class file we see this List listOfStrings; listOfStrings.add(""); String value = (String)listOfStrings.get(1); Here the compiler has palced the typecast for string.
Now my question is whether it is same in .Net??