Share on Facebook
In the series of
technical interview question, this is my second post. Here i am posting
very basic questions related with .NET concept. Following questions are
usually asked in any .NET interview.
Que1: What is serialization/Deserialization?
Ans: Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects.
Que2: What are the ways available in .NET Framework to support serialization?
Ans: There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter.
Que3: How can i customise the serialization process?
Ans: XmlSerializer supports attributes like xmlIgnore and xmlElement, that can be used to configure serialization. For example,by [XmlIgnore] attribute, we can exclude field/property from serialization and by [XmlElement] attribute we can specify element name to be used for a perticular field.
Que4: How can we serialize a Hashtable?
Ans: XmlSerializer will refuse to serialize instances of any class that implements IDictionary. So we need to customize our serialization process with attributes like xmlIgnore and xmlElement. We can pass array of Key value pair type object and on the other side can deserialize into Hashtable again.
Que5: What is CAS?
Ans: Code access security (CAS) is a feature provided by the CLR. Code access security is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running.
Que6: What is Boxing and unboxing ?
Ans: Boxing: The conversion of a value type instance to an object.
Un-Boxing: The conversion of an object instance to a value type.
Que7: What is difference between const and readonly?
Ans: const are evaluated at compile time, wherease readonly are eveluated at run time. const need to be initialized at declaration,but readonly can be declared once and can be assigned in the code also. const can not be static, but readonly can be static as well as instance-level.
Que8: What is delegate?
Ans: Delegate is reference to a method. It is similar to function pointer in c++.
Que9: What are events?
Ans: Events are ways of notification. When something interesting happens and we want to execute any function on that thing, we can associate events with that.Events are declared using delegates only.
Que10: What is advantage of for loop over foreach loop?
Ans: We can modify collection by adding new value while traversing on it by for loop, but in foreach, if we add any new value in collection, it will throw an exception. foreach loop requires collection to be enumerable,such constrant is not there in for loop.
Please go through the questions. The answers given are a little short and doesn't give the detail explaination. The topics covered here are very important, and i will suggest you to explore them in detail.