5

We're looking to hire a new junior C# developer. We're not looking for guru's or anything, so my boss asked me to write down a few questions and answers of varying difficulty to assess their skills.

My first question was "What does the using statement do".

So far after 2 interviews (both fresh out of college I think) both answered "used for including a namespace". After telling them not to confuse it with the using directive neither could explain what it does.

To me this seemed a fairly easy question for someone who has worked with C#. Am I wrong and is it a bad/confusing question?

12
  • 7
    Isn't a junior C# developer someone who hasn't yet worked with C#? Jul 13, 2015 at 13:52
  • 7
    wonder if you read what tag interview says, "DO NOT USE..."
    – gnat
    Jul 13, 2015 at 14:01
  • 4
    Statement versus directive leads to confusion. Give them an example using statement and ask the purpose. I think a better question is what does dispose do and when is it invoked.
    – paparazzo
    Jul 13, 2015 at 14:11
  • 1
    @Blam: Anyone who has used using and knows how it works wouldn't be confused. Jul 13, 2015 at 14:18
  • 9
    @RobertHarvey Anyone? I use it all the time and would not get the subtlety of statement versus directive. In that context you don't know that "statement" is clinical or general.
    – paparazzo
    Jul 13, 2015 at 14:24

3 Answers 3

7

It's not a bad/confusing question; it's basic language knowledge that's important for proper resource management. You've just found a few green interviewees who never learned about it in college.

4
  • 5
    A good answer to the OP's question would explain why you think it's a good interview question. Then again, this question's going to get closed anyway, so. Jul 13, 2015 at 14:11
  • When was it introduced? Because I don't think it was in the first version... Jul 13, 2015 at 14:26
  • @Deduplicator in the MSDN I can go back until Visual Studio 2005. As it seems it wasn't available before.
    – Knerd
    Jul 13, 2015 at 18:34
  • 2
    Why is it required (or expected) to learn about a specific language in college? Such things can be learned in my opinion. I guess if you want to test proficiency with C# in a production environment it's a fine question, though would that be considered junior?
    – Chris
    Jul 13, 2015 at 18:56
38

Remember, your job is to identify a talented guy, not someone who remembers the syntax of the language because they were taught to do so.

When you ask this question, chances are, your prospects have seen and used using statement before, however, were confused by the words statement and directive.

I am not a junior in any way, and first thing that popped in my mind when I read your question was the exactly that - the directive just because how much more prevalent the use of it is compared to the statement.

Another very important aspect, is you want a person who can think logically and learn code as they go - one way to gauge that is to show them the code samples - if the person is a good programmer, they will be able to understand what the statement does even without knowing the statement function in the beginning most of the time. Do the same to someone who learned the syntax religiously without understanding it and you might be up to a nasty surprise.

I would rather provide a prospect with code sample, and ask to describe what the statement does because in the end of the day, programmer will be looking at code 70% of the time. This way you eliminate confusion based on "interview fear" and might hire a talented person.

3
  • +1 - What's the point in asking questions in an interview that can be Googled.
    – JeffO
    Jul 13, 2015 at 18:51
  • @JeffO: To Google something, first you have to know what you're looking for. That's not always an obvious thing. Jul 13, 2015 at 19:00
  • 1
    @JeffO Well, anything can be Googled. I just believe questions should be asked to determine one's knowledge of the subject and not terms used to describe the subject.
    – Alexus
    Jul 13, 2015 at 19:46
8

I don't find it surprising at all. I'm a relatively fresh into the workforce developer, and I've been using C# at work for about a year. I've been using it for personal projects in the same time. I've written several apps, and several web-apps. I just had to look up the using statement to answer your question.

I've seen it in examples online, and it's obvious what it does when I see it, but I've never had occasion to use it in my code, and I wouldn't have been able to answer your question.

As I said, it's pretty obvious what it does. I looked up this article, and skimmed to this example:

using (TextWriter w = File.CreateText("log.txt"))
{
    w.WriteLine("This is line one");
}

source: Understanding the 'using' statement in C#

I still have never read or formally learned anything about a using statement, but I would guess from the example that the scope of the object is that code section, and it is deleted when the section elapses. If you show them something, and they're competent, they will have no trouble working with it. However, just asking what a using statement is is not a useful question, in my opinion.

2
  • 1
    Your guess misses the key part of using: There's an implicit try...finally in there that cleans up the item in the using. After that loop is done your TextWriter will be closed even if your loop crashes. Jul 13, 2015 at 22:23
  • 1
    I think your answer neatly proves @Alexus' point. Whilst you get it slightly wrong, you are able to make an educated guess at what it does (and had the sense to look it up!). This is far more telling of a person's development skills than being able to remember syntax.
    – David Arno
    Jul 20, 2015 at 16:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.