Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Questions every good .NET developer should be able to answer? [closed]

Tags:

.net

People also ask

What every .NET developer should know?

NET developer should have skills of creating highly creative, catchy and interactive web applications. This increases his value in the market. In order to achieve that, understanding of client side technologies like HTML, CSS and JavaScript, jQuery and Bootstrap is a necessity.


Basic questions include:

  • Whats the difference between an abstract class and interface? When would you want to use them?
  • What's the difference between a left join and an inner join?
  • What's the difference between viewstate and sessionstate?
  • What's the difference between overriding and overloading a method? Explain how both are done.
  • What's the difference between protected and internal? What about "protected internal"?
  • How do short-circuited operators work?
  • Explain what the StringBuilder class is and why you'd want to use it?
  • What's the difference between a static method and a non-static method?
  • What does the "volatile" keyword in C# mean?
  • Explain what happens when you pass a "ref" or "out" parameter into a method. What's the difference between those two keywords?
  • What's a weakreference? When would you want to use one?
  • What's the difference between a DataTable and a DataReader?
  • What's the difference between a value-type and a reference type?
  • What does the "readonly" keyword in C# mean?

I think it usually helps to ask your applicants to complete a simple coding exercise such as:

  • Write your own linked list class without using the built-in classes.
  • Write your own hashtable class without using the built-in classes.
  • Write a class that represents a binary tree. Write a method that traverses all nodes of the tree.
  • Write a method to perform a binary search on an array without using built-in methods.
  • Draw a database schema for a blog. Each user only has one blog, each blog has many categories, each category has many posts, and each post can belong to more than one category. Ask your applicant to write queries to pull specific information out.

Next, look for specific technical know-how:

  • (Event handlers) Create a class with a custom event handler, create another class which hooks onto the custom event handler.
  • (XML) Load an XML document and select all of the nodes with properties x, y, and z.
  • (Functional programming) Create a function that accepts another function as a parameter. A Map or Fold function works really good for this.
  • (Reflection) Write a function which determines if a class has a particular attribute.
  • (Regex) Write a regular expression which removes all tags from a block of HTML.

None of these are particularly difficult questions for a proficient C# programmer to answer, and they should give you a good idea of your applicants particular strengths. You may also want to work in a few questions/code sample that make use of specific design patterns.

[Edit for clarification]:

Seems that a lot of people don't understand why I'd ask these types of questions. Let me touch on a few peoples comments (I'm not quoting directly, but paraphrasing instead):


Q: When was the last time anyone used volatiles or weak references?

A: When I give technical interviews, I look to see whether a person understands the high-level and low-level features of .NET. Volatiles and weak references are two low-level features provided by .NET -- even if these features aren't used often in practice, answers to these questions are extremely revealing:

  • A good understanding of volatiles demonstrates that a person understands how compiler optimizations change the correctness of code, how threads keep local copies of shared state which may be out of sync at any given time, and is minimally aware of some of the complexities of multithreaded code.

  • A good understanding of weak references demonstrates that a person knows about the intimate details of the garbage collector and how it decides when to free memory. Sure, you could ask candidates "how does a garbage collector work", but asking about weak references gets a much better, more thoughtful reply.

.NET is a fairly abstract language, but star developers almost always have a deep understanding of the CLR and the low-level details of .NET's runtime.


Q: Why would anyone need to implement their own hashtable or linked list?

A: I'm not implying that the Dictionary class is inferior or that people should roll their own hashtable. This is a basic question which tests whether a person has a minimal understanding of datastructures. Thats what these questions test for: bare minimum understanding.

You learn about these hashtables and linked lists on the first day of Data Structures 101. If someone can't write a hashtable or a linked list from scratch, then they have a huge gap in their technical knowledge.


Q: Why are these questions so crud-oriented?

A: Because the title of this thread is "questions every good .NET developer should know". Every .NET developer begins their career writing crud apps, and 90% of all application development people do for a living is concerned with line-of-business applications.

I think questions testing a persons knowledge of line-of-business apps are appropriate in most cases, unless you're looking for developers in very specific niches, such as compiler development, game-engine development, theorem-proving, image processing, etc.


I found these lists on Scott Hanselman's blog:

  • What Great .NET Developers Ought To Know (More .NET Interview Questions)
  • ASP.NET Interview Questions

Here are what I think are the most important questions from these posts divided into categories. I edited and re-arranged them. Fortunately for most of these questions there is already a good answer on Stack Overflow. Just follow the links (I will update them all ASAP).

Platform independent .NET questions

  • What is the difference between a thread and a process?
  • What is the difference between an EXE and a DLL?
  • What is strong-typing versus weak-typing?
  • What is the difference between a.Equals(b) and a == b?
  • What is boxing?
  • Is string a value type or a reference type?
  • What is the Global Assembly Cache (GAC)? What problem does it solve?
  • What is an Interface and how is it different from a Class?
  • What is Reflection?
  • Conceptually, what is the difference between early-binding and late-binding?
  • When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
  • What is an Asssembly Qualified Name? Is it a filename? How is it different?
  • How is a strongly-named assembly different from one that isn’t strongly-named?
  • What does this do? sn -t foo.dll
  • How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
  • What is the difference between Finalize() and Dispose()? (external article)
  • What is the difference between in-proc and out-of-proc? What technology enables out-of-proc communication in .NET?
  • What is FullTrust? Do GAC’ed assemblies have FullTrust?
  • What is the difference between Debug.Write and Trace.Write? When should each be used?
  • What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
  • What is the difference between: catch (Exception e) {throw e;} and catch (Exception e) {throw;} ?
  • What is the difference between typeof(foo) and myFoo.GetType()?
  • What is the purpose of XML Namespaces?
  • What is the difference between an XML "Fragment" and an XML "Document"? (XML Basics)
  • How would you validate XML using .NET?

ASP.NET

  • What is a PostBack?
  • What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? Why is it either useful or evil?
  • What Session State providers are available in ASP.NET? What are the pros and cons of each?
  • What is the OO relationship between an ASPX page and its CS/VB code behind file?
  • How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated via all values of q= except where q=5 (as in http://localhost/page.aspx?q=5)?
  • What are HttpHandlers?
  • What are HttpModules?
  • What is needed to configure a new extension for use in ASP.NET? For example, what if I wanted my system to serve ASPX files with a *.jsp extension?
  • How do cookies work? What is an example of Cookie abuse?
  • What kind of data is passed via HTTP Headers?
  • How does IIS communicate at runtime with ASP.NET? Where is ASP.NET at runtime in the different versions of IIS (5 to 7)?

This might not be what you want to hear, but I would recommend not focusing on narrow technologies, but on general programming and problem solving skills. Solid developers can learn whatever you want them to do quickly.

I, for instance, am not a Compact Framework guy, so I might fail your interview if you went that direction. But if I needed to use it I could do some research and jump right in.

Joel's book, Smart and Gets Things Done, has great advice for hiring devs and there are large juicy sections about the kinds of questions to ask. I highly recommend it.


I think if I were interviewing someone who had LINQ experience, I'd possibly just ask them to explain LINQ. If they can explain deferred execution, streaming, the IEnumerable/IEnumerator interfaces, foreach, iterator blocks, expression trees (for bonus points, anyway) then they can probably cope with the rest. (Admittedly they could be "ok" developers and not "get" LINQ yet - I'm really thinking of the case where they've claimed to know enough LINQ to make it a fair question.)

In the past I've asked several of the questions already listed, and a few others:

  • Difference between reference and value types
  • Pass by reference vs pass by value
  • IDisposable and finalizers
  • Strings, immutability, character encodings
  • Floating point
  • Delegates
  • Generics
  • Nullable types

I'm with the guys that are looking for problem-solving abilities rather than the sort of thing you can look up and memorise from '101 top .NET interview Qs and As".

Just to cite myself as an example, I tend to 'know' the things I need to use from day to day. I tend to forget (and later have to re-look up) things that I use rarely.

If you wanted to trip me up in an interview, it would be very easy.

Nevertheless, I have architected and coded much of the infrastructure for a system that uses identical Business Objects and Data layers for its WinForms and ASP.NET incarnations, and our codebase is robust and reusable enough for us to be able to support and develop 20+ differently configured versions of the web site, as well as an increasing number (currently 5) of the WinForms application...

... with a development team of two.

I used to work on a team as a tech lead, and my job involved quite a lot of recruiting and interviewing. My most spectacular mistake was hiring a guy that knew more about the technology we were using than all the rest of us put together, including me, and I counted myself as an expert. He knew everything...

... except how to write code that either met the requirements, or could be understood by anyone except himself. When I eventually persuaded the PM not to renew his contract, every single thing he wrote had to be rewritten.

Structure your interviews wisely...


Who is Jon Skeet?