I Code, Therefore I Am

while(!(succeed == try()));

Ten C# interview questions

If you’re hiring a developer, in this case a C# developer, it can be a daunting task to tell if they’re as knowledgeable and good as they say they are. Here is a list of 10 interview questions that I think will help you decide if you’re interviewing the right (talented) person (well it should show if the candidate knows what he/she is talking about):

  • Why would you use a StringBuilder over a String?: StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
  • What exactly is a delegate? A delegate encapsulates a reference to a method. In C++ they were referred to as function pointers.
  • What’s the difference between the Array.CopyTo() and Array.Clone()? The first one performs a deep copy of the array, the second one is shallow.
  • What namespaces are necessary to create a localized application? System.Globalization, and System.Resources.
  • What’s the .NET datatype that allows the retrieval of data by a unique key? HashTable.
  • What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
  • What exactly is a satellite assembly? When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
  • What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception? A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
  • Can multiple catch blocks be executed? No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
  • Why is it a bad idea to throw your own exceptions? Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.

To see the full list go to TechInterviews.com.


About The Author

Richard has been a professional software developer for over 15 years now. In fact he was a geek long before being a geek was 'cool'. He has his Bachelors in Computer Science from The University of Georgia and is an avid, passionate .NET developer. Richard eats, sleeps, drinks and dreams in code

Comments

3 Responses to “Ten C# interview questions”

  1. Srdjan says:

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

    The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy.

  2. You’ve got some excellent points there. At my last office job I had to stand up and write code on a whiteboard in front of the higher ups in the IT department, and I see nothing wrong with asking possible new hires to take this route

  3. I don’t know if I agree with the statement “Throwing your own exceptions signifies some design flaws in the project.”. This may be true at the UI level, but if you pass a null id into the data layer, I think it should still throw the ArgumentNullException.

    With the rest of the questions, I wonder if you can force the user to show you their knowledge without asking. Maybe you can create a white board coding test where they need to demonstrate their knowledge in that area. For example, maybe you can ask them to create a class to write a fixed width text buffer. You would probably expect a StringBuilder at the core of this class. If they don’t use a StringBuilder, you can ask them if there’s a more efficient way & see what they say. Keep giving them easier & easier hints until you tell them the answer, to get a feel for if they know it.

Leave a Reply