General C# Questions


One of my career goals as a developer is to work for Microsoft, now that I have graduated school and have 2 years of development experience I am going to start actively perusing this goal. The word on the street is that the interview process for Microsoft positions is not easy. To prep for interviews I am trolling the web looking for possible interview questions and posting my answers. To start off I found these general questions on C#.

1. What is metadata? What information is stored in Metadata?

Metadata describes every type and member defined in your code in a language-neutral manner. It stores the description of the assembly, description of types, and the attributes

2. What are some of the Tables stored in metadata?

Each metadata table holds information about the elements of your program. For example, one metadata table describes the classes in your code, another table describes the fields, and so on. If you have ten classes in your code, the class table will have tens rows, one for each class. Metadata tables reference other tables and heaps. For example, the metadata table for classes references the table for methods.

3. What are the two basic kinds of types in .net framework?

Two basic kinds of types are value types and reference types.

4. What is boxing and unboxing?

Boxing a value type packages it inside an instance of the Object reference type, unboxing is the reverse.

5. What class does all classes implicitly inherited from?


6. What is namespace, assembly?

Namespace declares a scope that lets you organize code and gives you a way to create globally unique types. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality.

7. What is global assembly cache, what is the purpose?

The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.

8. What are Primitive types?

Any data types directly supported by the compiler are called primitive types. Primitive types map directly to types that exist in the base class library.

9. What is reflection?

Reflection allows the inspection of metadata in a PE file and late binding (run time) to types and their members.

10. What is a delegate?

A delegate is a type that references a method with the same signature.

11. Describe the accessibility modifier “protected internal”.

Access is limited to current project or types derived from the containing class.

12. What does the term immutable mean?

It's simply a class that’s state does not change after it was initialized.

13. What’s the difference between System.String and System.Text.StringBuilder classes?

StringBuilder class represents a mutable string of characters. System.String is immutable.

14. What’s the advantage of using System.Text.StringBuilder over System.String?

A StringBuilder object is preferable for a concatenation operation if an arbitrary number of strings are concatenated; for example, if a loop concatenates a random number of strings of user input.

15. Can you store multiple data types in System.Array?

No, array objects with the same array type share the same Type object.

16. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

CopyTo() is a deep copy that copies the values. Clone() is a shallow copy that copies only the elements of the Array.

17. What’s the .NET collection class that allows an element to be accessed using a unique key?

System.Collections.Hashtable or System.Collections.Generic.Dictionary, I prefer the Generic Dictionary it is faster.

18. Will the finally block get executed if an exception has not occurred?


19. Can multiple catch blocks be executed for a single try statement?

No, the order of the catch clauses is important because the catch clauses are examined in order. Catch the more specific exceptions before the less specific ones.