C# Interview Questions

For some reason, majority of C# .Net phone screenings ask, over and over again, the same meaningless questions. In my opinion, no self-respecting company, should make any decision based on these questions. Anyway, the reality is that you either hire or get hired. So I created a list of questions that helps me to ace phone screenings:

The only difference between executable and library assembly is that library assembly does not contain main entry point.
All assemblies contain metadata that describes its types and methods.
Assemblies also contain manifest (assembly metadata) that describes assembly itself (version and so on).
All private assemblies are located in the same folder (or its subfolders) as the main executable assembly. Shared assemblies are located in the GAC folder.
Anonymous type is a nameless class that inherits from object.
For instance: var person = new {firstName = “Me”, lastName = “You”};
Structs unlike Classes are value type (not reference type and are being stored in the stack and not on the heap) and do not support inheritance.
Extension methods are a simple way to extend classes that do not have source code available. All you have to do is to create a new class that contains a function that has the class you want to extend as a first parameter, preceded by this keyword.
Sealed classes cannot be inherited from.
Virtual methods can be overridden by derived classes(derived classes use override keyword for safety reasons – in case you did not notice that the method does not have exactly the same signature as the virtual method you will get an error).
Internal visibility modifier makes the class visible only to containing assembly.
Interfaces contain only public methods – no protected, private, or even abstract or static. Interfaces can inherit from each other though.
foreach loop can only be used with classes that either implement IEnumerable interface or implement GetEnumerator, MoveNext, (Reset), and Current members.
Use checked block to enable overflow cheking.
Boxing converts value types to reference types.

Leave a Reply

− 4 = four