Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Are there any books for C# developers that will help me to improve my performance answering programming questions during an interview? I need practice, and need to work on algorithm types of questions.
Introduction to Algorithms, second ed.
I'd highly recommend the O'Reilly book "C# Cookbook" since it will give you specific algorithm implementations. Another good one is "Algorithms in a Nutshell", for more language agnostic algorithms.
O'Reilly - C# Cookbook
Algorithms in a Nutshell
As someone that interviews potential developer for my team, I really would rather you didn't try and "game" the interview. If you study for interview type questions you might get really good at it, but then would you be a good developer?
Other than for graduates, who I expect to be learning on the job, any other level of developer will get task to perform in Visual Studio. The candidate will be asked to write a small program in the space of about 4 hours. It will contain all the elements necessary to determine if they are any good or not and we can see examples of their real programming style, thought processes and abilities.
The worst person I ever interviewed was someone who had learned the "standard set" of questions by rote. When we asked a question he knew we got a beautifully crafted answer back. But, when he was asked something he didn't know we got back an instant "I don't know". Some of the questions were logical questions, we didn't expect anyone to know the answer off the top of their head, they were expected to work it out.
So, just learn how to write software. Learn how to communicate that to other people and you'll do just fine in the interview.
"Programming Pearls" by Jon Bentley, nothing to do with C# per se, (it was first published 14 years ago), but is great book on programming problem solving in general
I like Algorithms in a Nutshell.
Edit: and The Algorithm Design Manual is fun, but don't start there.
I highly recommend "C# in Depth" by our fellow Jon Skeet. :)
You asked about books, but I will advise trying one of the following:
Project Euler
Top Coder (they support C# solutions)
UVA Online Judge
SPOJ
The more You solve, the better You will be at algorithms.
PS: Don't get addicted:)
This might be what you're looking for.
It's what I used in my algorithm class.
I would decide first if you need work on C#, or on algorithms, or on both. It sounds like you're worried about "algorithms in C#", which you shouldn't be. Algorithms are essentially the same across all the common imperative programming languages. If you're really worried about algorithms, you can pick up pretty much any algorithms book and work through it. Same thing with C#.
A lot of "programming type questions" on interviews, unfortunately, tend to be either "do you know this minor tidbit of this language?" Sadly, there's not much you can to do study for those types of questions, other than use the language a lot and become increasingly familiar with its details.
Data structures and the framework they're within, however, are a bit different. In a (relatively) short time you can become familiar with some aspects of the .NET framework that can help considerably. Learning things like how to use generics and how to get a hashtable or a list is good to know. Of course, then you should also know the more general answer of when you should use a hashtable vs. a list.
For general programming questions related to .NET technologies, I wrote an eBook called "Shove It, FizzBuzz: How to Find and Land a .NET Development Job."
http://shoveitfizzbuzz.com
It's more than just interview questions, but it's still chock full of them, and comes with a .NET Interview Simulator.
Related
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am very eager to learn in depth OOP concepts and most importantly how they can be applied in "real life". So far, I have read many references and many tutorials online but they all lack something: They do not provide a way to fully understand how object oriented programming can be truly used. In fact, it seems that most tutorial focus on OOP "syntax" as opposed to "the art of OOP design". Since OOP is a set of concept/idea/best practice in thinking about a problem and tackling that problem in a way to allow a better productivity I really want more. I want something to help me think as an "OOP designer" and not an "OOP programmer". Can someone provide with me a resource (preferably an online resource) that actually provides a non trivial example on how to apply OOP? Although I am aware that OOP is language agnostic, I would prefer examples in C#.
IMHO the best resources are not available online. This former SO post contains pointers to some very good books:
https://stackoverflow.com/questions/3315633/which-is-the-best-book-to-learn-and-implement-design-patterns-using-c
Check the following books;
Object-Oriented Analysis and Design with Applications
Code Complete
Design Patterns Explained
Not sure online versions avialable
http://www.amazon.com/Object-Oriented-Programming-Peter-Coad/dp/013032616X
Code Complete
http://www.exforsys.com/tutorials/oops.html
http://www.clear.rice.edu/mech517/Books/
Head First Design Patterns ( its in java but really good)
http://shop.oreilly.com/product/9780596527730.do
http://www.amazon.com/gp/reader/0201633612/ref=sib_dp_pt#reader-link
http://www.amazon.com/Design-Patterns-Explained-Perspective-Object-Oriented/dp/0321247140/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1211844244&sr=1-1
Good question. I've read many of the books that are suggested here, but I still struggle sometimes with good object design. In fact I've become somewhat disillusioned with Object Design. I think two books that are worth reading are
Robert C. Martin - Clean Code
Robert C. Martin - Agile Principles, Patterns, and Practices in C# (but be aware that the C# code is a bit outdated)
see this question and answers: What is the single most influential book every programmer should read? there really great books mentioned there(not just OOP).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Ok here is my situation. I've studied Java in my college for 2 semesters. But you know they teach you jack in there, just the basics. We skipped half of our textbook and even then our professors don't teach from section to section of each chapter. I don't blame them. It's hard as it is for new students to understand even the basic concepts of programming. Now this is a community college we are talking about and not Stanford, MIT or Berkeley.
So like I said I've done 2 semester of Java. I really like our textbook because it has some challenging projects to do at the end of each chapter. This textbook is pretty clear and i have no problem understanding it (although 2-D and 3-D Arrays have given me some trouble). I have tried reading a few C# books such as Pro C# 2008 and .NET 3.5 and C# 4.0 in a Nutshell. I found these books to be dry and overloaded with information that put me to sleep (No offense to the authors of those 2 wonderful, according to amazon ratings, books).
Would you suggest I finish my Java textbook, brush up my knowledge of Arrays, Polymorphism, and etc that are universal to most programming languages. And then switch to C#, plus the syntax is very similar so it should be easy to switch. Or should I just start learning C# right now from the very beginning? If it's the latter then could you recommend some free online resources that will keep me engaged and at the same time teach me everything I need to know about C#.
Someone has recommended me to learn .NET first, but I found it to be not the brightest idea. .NET is just a big monster full of libraries. How am I going to apply it if I don't even know the C# or VB!? Anyway back to my question: Master Java and switch to C# or just go with C#?
DISCLAIMER: I don't want to start .NET vs J2EE or C# vs Java flame war. I am going with C#. I've decided that I want to work in a Microsoft shop in the future. .NET is what I want to learn.
Thanks! Will be waiting for the answers.
I found myself in pretty much the same situation as yourself whilst studying Java at community college - I am smiling right now :). That was 10 years ago and D flat, as some wags were calling it, was starting to make some noises.
What I did, was do all of my assignments in both C# and Java, so that I could get to grips with both. I then begged to do my final year project in C#, which they eventually relented on. Getting practice in a couple of languages and doing a major project will stand you in good stead.
I have never looked back. Good luck! :)
Both Java and C# concepts and syntax are very similar.
I would concentrate on the one you expect to use after completing your studies. Look at which is asked for more often in the area you are intending to work.
As a side note, C# 4.0 in a Nutshell is an excellent book both for learning and reference. Suggest you give it another go.
I think I found the answer to your question...in your question.
For now, go ahead and finish your Java book as a way of continuing to learn the fundamentals of OOP.
Next (or while finishing the Java book), shift your focus to C# and the .NET framework (in most business situations, you'll be hard-pressed to find one without the other).
If you want to focus more on language elements of C# rather than a specific framework (such as ASP.NET, Silverlight, Windows Forms, or WPF, to name a few things), you might consider a book on LINQ, such as LINQ in Action from Manning Press. Combine your knowledge of LINQ with trying to solve some problems at http://projecteuler.net and you should start picking up the language pretty quickly.
Personally, I read Illustrated C# 2008 by Daniel Solis. Granted, it's not a textbook filled with lots of fun and challenging examples, but it is a good exposition of the language.
Don't worry so much about any particular language, and "Teach yourself programming in 10 years": http://norvig.com/21-days.html
Since it sounds to me like you don't really know a lot about programming, and this is largely your first major exposure to it, I think it's absolutely in your best interest to stick with something until you have learned enough of it that you are satisfied with your skill level. Jumping now may hurt you later, because you will be covering a lot of concepts you probably already know.. but hidden inside will be something you don't, and thus you will skim right over it.
Keeping yourself "engaged" is only something you can do, not the text. Certainly some texts are more interesting than others, but you have to be committed to reading the material whether or not you find it boring. That's how you learn.
Both Java and C# are syntactically similar at the basic level, but they both diverge from there in different directions and do similar things in different ways. Further, the languages are largely useless without the base class library, and those are often very different between languages.
What you didn't mention was how you are doing in school. Does your school require you to do more java work? If so, then you will have to stick with it. If not, and you are "done" with it, then perhaps starting over with C# from the beginning would not be a bad idea. Just think of C# as a new language you have to learn from the ground up, even if much of it seems familiar.
I found the Wrox book series to be particularly good to learn from, along with the Head First book series. As for which one to continue I would say it depends on what you are tested on. If you have to do written exams and write out sample code. You don't particularly want to start banging out C# by accident.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
What are the various sites that offer metrics that compare Ruby, Python, Perl, Smalltalk etc. What are their respective metrics?
Do any of them control or account for the time that Rails was introduced, and/or the adoption rates for various languages?
Will someone please help me close this question? Clearly it was not a successful venture :-)
I don't mean to be nasty but what you are saying sounds like this to me: "I enjoy programming in Ruby and really don't want to learn another technology. Is there a site that can tell me that Ruby is not going away anytime soon to put my mind at ease?".
There is nothing wrong with that attitude but you have to be prepared to adapt to the changing environment and learn new technologies, techniques, do a little self-improvement if you want to remain competitive. Plenty of people are comfortable using five different programming languages. Boxing yourself into a narrow field will eventually disadvantage you.
You will also find that learning a second language is a lot easier than the first one. At the end of the day good programmers transcend the language barriers. This is what you should be doing instead of reading metrics that tell you that your language of choice is still popular.
TIOBE attempts to rate the popularity of programming languages. Ruby is in the top 10 just below Perl. Therefore I would say that your investment is protected. As or what the index actually measures they can explain it better than I can.
Better than Google trends is Google insight. It allows you to limit queries to a given subject, like eg programming. And since all of smalltalk, ruby, python, and perl are also used in other context, I limited the search to programming.
http://www.google.com/insights/search/#cat=31&q=smalltalk%2Cruby%2Cpython%2Cperl
If you choose "growth relative to category" the boost of Ruby search queries in 2005 is striking.
Also, see Google trends comparing number of searches for ruby, python, php and perl over time.
One of the more interesting metrics is the State of the Computer Book Market posts that Mike Hendrickson posts on his O'Reilly Radar blog. I tend to favor metrics that are tied to the exchange of value rather than spotty things like the number of search engine queries. His latest post doesn't drill down into topic areas, but sometimes they do (using nice TreeMaps even).
Don't Worry
I also like Ruby1, and I worried about exactly the same thing.
But a closer look at the same data allayed my fears.
Ruby's Tiobe Index score has been fairly stable, after a big jump in popularity when Rails exploded onto the scene.
Ruby is in the top ten, albeit in the 10-slot. That's really quite good. It will pass Perl any day now and be #9, and may someday pass VB and, who knows, perhaps even C++.
Perhaps an initial decline was expected. Not long ago, hardly anyone knew Ruby, but lots of us knew the other languages. So perhaps a temporary flurry of Ruby activity was expected as people got up to speed.
Ruby is a great language. C and Java rule the world because both languages really do solve certain problems effectively. Ruby does too and it has the attention of the technology trend-setters. How much better could it really get?
You can learn another language easily. There is a worry, just not the one you identified. The problem is you won't want to work in lesser languages after learning Ruby and RoR.
1. The original version of the question revealed a concern about the future of Ruby.
I usually use Google Trends for this:
http://www.google.com/trends
The more popular an item is (in this case a language) the more that people are searching for it.
If you look at this chart on Google Trends:
http://www.google.com/trends?q=+Ruby,+Python,+Perl,+Smalltalk
you'll see that they've all stayed pretty much flat except for Perl that's been steadily declining.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm conducting an interview in 45 min (my second ever!) for a candidate who's pretty junior and states she knows VB and C#. I do not have any experience in either of those languages.
Does anyone have any good simple interview questions for these languages that I can ask that will be informative without being too intimidating?
Note: I'm looking for language-specific ones, and not of the FizzBuzz variety (which I'm already planning on asking).
Related Question
https://stackoverflow.com/questions/70763/good-c-interview-questions-for-a-senior-dev-position
UPDATE: It's over - and thanks everyone! As Jon Skeet says - it's hard to ask questions to which you don't know the answers but I did find that her reaction to the question being asked, even without the answer, was pretty telling and showed me immediately whether or not she was familiar with the concepts being presented.
The problem with asking language-specific questions for a language you don't know yourself is that if any of the answers deviate from the specific ones you've been given here, you won't know if they're right or not. (I humbly suggest that most of the answers given so far suffer from that problem.)
Do you have a laptop available, so you can get them to code and see whether the result is the desired output? If so, FizzBuzz-style questions are a good start, and while you won't be able to judge the idiomatic style of the code you can at least see if it works :)
I find that a useful question to ask is what the candidate likes and dislikes about the language. What would they change if they could?
There are numerous lists on the web.
The C# ones one Mark Wagner's blog are quite good and range from the fairly simple to quite hard so you can go as deep as you like. However, as the commentators have pointed out some of them are in danger of becoming out date (if they're not already) - so use them as a guide.
Look here, maybe you can pick up something not too senior:
Questions every good .NET developer should be able to answer?
Good C# Interview Questions for a Senior Dev Position
I'm no expert on interviewing, so please take this as an opinion rather than gospel.
I'd ask the interviewee to bring in a hundred lines or so of code they've written in each language that accomplishes something interesting. In the interview, let them know what languages you do know, and ask them to review their code with you. Even without knowing the language you should be able to ask questions about various design decisions and determine whether the interviewee is actually comfortable with the language.
I think it is far more important to find out how the candidate thinks than to test their specific knowledge on a topic. For example, they may know C# but do they have the aptitude to learn VB.NET, or F#, or some other language. What makes them tick? Do they get excited by new framework features? What do they do for hobbies? How do they tackle problems? These things are far more important than knowing a language inside and out, especially when even the best developers still rely on the compiler to tell them they screwed up.
Its very dificult to answer your question, because we can list thousands of questions. However here is my abstract idea:
Test whether he knows all OOPs concepts and how it can be acheived in C#/VB.Net
Avoid critical questions as they are juniors.
Test them whether they can differntiate .Net languages from other HLL
Explain some .Net features and ask how they will achive them using C#/VB.Net
(ex: Reflection, Genrics, property)
Make sure that they can very-well pick-up if they given chance to work.
How about asking which strengths and weaknesses do she sees in each language? What would make one more appropriate than the other?
Note that while one could say that she isn't so familiar as to know an answer, that in itself can be a fine answer. Part of what you are wanting to see is their ability to communicate either technical arguments for or against something or an ability to say, "Well, I don't have enough experience to give a thorough answer on this."
I usually interview people for c# developer role. I have found questions at the following URL very helpful for Junior, Mid and Senior developers. You can find a variety of c# interview questions segregated by topic. Here is the URL C# Interview Questions
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've been programming for a few years in C# and XML. I used only the basics of those languages and have survived on the web for info like arrays and text manipulations. But when I am get interview, the interviewers ask only advanced questions - I found the answers later in the Advanced sections in the books on the subject.
Why do the interviewers ask such advanced questions? The job looks almost the same as what I was previously doing, so there's need for advanced knowledge, like what class delegate is or XPath commands.
Questions are:
What version of XSL does .NET 3.5 uses?
What XPath command to use to get value in element X?
What are class delegates in C#
Does C# allows multiple interface inheritance?
How do you access GAC in C#?
There are two reasons that I ask them.
To see a person actually say "I do not know the answer to that", as opposed to trying to BS through the question.
To see what kind of logical problem solving skills a person has.
Usually a question will be of one or the other, but not both. Both are extremely valuable in screening a perspective employee, however.
Also, the question might not actually be "advanced" for the position. It is reasonable to assume that Senior-level and/or Architects can answer questions that a Junior to Mid-level might not.
Perhaps because they are trying to find programmers who know more than the basic stuff. If they are trying to distinguish between a field of candidates, it isn't helpful to ask questions that everyone knows the answer to - how do you select among those candidates? If you're going to hire only 1 or 2 out of a pool of candidates, you need to find some harder questions that only 1 or 2 out the pool can answer.
Getting the answer wrong is what I want from an applicant in some cases.
One of the reasons I like to ask a question that I think the applicant will get wrong is to see how they adjust to the situation. How they handle getting something wrong and handle someone telling them how they should have answered etc. If they are very defensive or rude when you tell them they are incorrect then it is a good indication of how they will work on a team when many times your ideas will be challenged.
If they take the solution or recommendation and realize they can learn from it or even add to it that is usually a sign of someone what is easy to work with and willing to work 'outside of their box'. If they just make excuses and dance around trying to say why they could be right or should be right (in cases where they are clearly not) then this tell me when the same issue arises in the future this applicant is going to cause headaches.
Not so worried about the answer, more interested in how they react to the question / solution.
Another reason would be to gauge their level when hiring as well. You might be hiring for a bunch of positions but not sure where this applicant fits. Hard questions that show problem solving and attention to detail can sometimes make it easier to categorize their skill set.
I ask advanced questions for a few reasons:
Some of my questions are advanced usage of things everyone should know (not a trivia question) -- I want to see you reason through the answer using knowledge you have, but in a way that isn't common.
I want to see what happens when you don't know something -- do you give up?
I want to hire people that are serious about what they do. People that really care about the technologies they use tend to want to know the advanced stuff.
I want to see if there are gaps where you just don't know that an entire area of knowledge even exists. For example, in your XPath example -- I might be ok with: "I believe that XPath could be used to help solve this, but I don't know it well enough to write it out here" -- then I would show them a little XPath and see if they could apply it. If you don't even know that XPath exists, google isn't going to help you.
Likely they're just getting a gauge of where you are. They probably got stuck on this problem themselves and perhaps wanted to see if you could think of an answer on your feet.
I've experienced the same types of questions, and considering when I program I use excessive resources, this type of thing usually throws me off. Their loss.
Because competency as a programmer involves both depth and breadth of knowledge.
The interviewer is trying to devine your level of knowledge, and he is copping out by "borrowing" a question from the last chapter of that book.
Really, this is sloppy work on his part, relying on one question to guage your expertise level. You may have low programming skills, but recently come across the buzz-word, and are able to ace the interview.
I did get burned once in interviewing a candidate who professed high levels of C expertise. It turned out that he was reading "C for Dummies" and managed to BS through the interview process. I admit that I wasn't concentrating on his programming skills, but was looking for other aspects, which he also managed to BS through. Turns out his whole resume was a pack of lies.
Nowadays, I make sure the candidate has working knowlege of variable scope, persistance, pointer arithmetic, basic algorithms, structured programming, object-oriented programming, polymorphism, multitasking and inter-process communication. I will quiz him on his debugging skills, and zero in on details such as race-conditions, heisenbugs and security vulnerabilities.
Depending on the job, I will ask about experience in the target language - such as key=>value maps (arrays) in PHP, Swing programming in Java, event handling in C#, tables vs CSS in html -- you get the picture.
If the candidate passes the first part of the interview (I usually know within about 5 minutes), I will then give him a binder and send him into the coffee room (nice couch and table there) to prepare for 20 minutes for a code review on a selected module.
That's when I send in the troops - employees are instructed to use the coffee room normally, introduce themselves and make conversation for about a minute.
What I'm looking for is the ability to concentrate on a task (blatant ADHD), the ability to work under pressure, and interpersonal dynamics.
When the candidate returns, I have him act as main presenter and start our normal code review process. The first thing I look for is if he read the page titled "Code Review Process". I'm not looking for him to complete the review - about 10 minutes is enough. As a matter of fact, the fewer main lines processed, the better - within reason.
I haven't been burned by a new hire for a long time now.
Your username suggests you like coding (duh), but your question suggests you don't. If you really liked coding, then you should love to learn about it. Those questions that you listed are not that advanced.
Even if those questions were advanced, the interviewer is trying to gauge how much knowledge you have in the area that you say you have knowledge in. They are also trying to gauge how well you would fit into their group.
P.S. Not to be mean, but if you program using XML and don't know what XPath is, then you are a little far behind.
They probably want to see if you really know what you're talking about or if you're a novice programmer who gets along on the web using only what he has picked up through trial and error...
1.What version of XSL does .NET 3.5 uses?
Because they can't tell important things from non-important ones. Bad sign.
2.What XPath command to use to get value in element X?
Because they want to see if you know XPath. This can be either because they use it extensively and you need it to get they job done or because they think XPath knowledge == skill.
3.What are class delegates in C#
(I've never heard the term "class delegate" and a google search shows no definition, so I assume you mean just "delegate").
Delegates can hardly be considered an advanced topic.
4.Does C# allows multiple interface inheritance?
If they really asked about "interface implementation", it's part of the most basic concept so it's a valid question (although too simple to really mean anything). If they really asked about "interface inheritance", it's more of trivia, but I would still say acceptable. Bonus point for them if they asked what "interface inheritance" really means.
5.How do you access GAC in C#?
This is the kind of thing every team MUST have one person who knows. I'd say it's also a indication of seniority (which BTW, I don't care much about) since nobody reads about these things, the only way to find out is to be forced to solve a real-world problem.
I ask advanced questions to try see how people work through the problem. I like to ask questions that I don't know off the top of my head for that reason.
I want someone who is a critical thinker rather than just an academic who can recite text books to me.
They want to find someone with practical experience that extends beyond what is taught in beginner courses. When my company interviews candidates, we often find that most of the applicants cannot solve what we would consider to be very basic programming problems simply because they don't know the API or don't understand when to use various basic data structures.
If you want to impress an interviewer, work on your own programming projects outside of class. Learn a good chunk of the language API, and start learning about third-party libraries that can greatly simplify your work.
Another reason is to gauge your response to a question they really don't expect you to know the answer to. Problem solving skills are essential, so asking you questions you already know the answer to is not going to address that, is it?
There are even instances of companies asking odd, non-programming related questions just to see how you think your way through a problem. There is the classic "Why are manhole covers round" question, reportedly asked at Microsoft interviews.
More Microsoft interview questions
I'm not meaning to offend you but maybe your understanding of the job is not deep enough and it in fact requires knowledge of advanced techniques.
Also, you can do a lot of things with basic methods but advanced methods might the better way to implement regarding complexity, time to implement or maintainability.
There are many possible reasons. They may:
actually use those techniques (delegates and XPath aren't particularly rare or obscure)
have a large pool of candidates and want to try to find the more knowlegable ones
want to see where the limits of your knowlege are, so they ask question up to the point where you start to be unable to answer well
want to see how you might approach areas that are unfamiliar to you - to see how you might adapt to new stuff
want to show off their own knowlege (probably not a legitimate reason, but it certainly happens)
I've heard these really aren't in use anymore, or at least not nearly as much as they used to be, but you might be interested in this. I picked up a pretty cool short book a few days ago that has to deal with the "Microsoft style" logic interview questions that are sometimes asked. I'm a few chapters in and it gives a neat little history of the tech field's interview style and has a ton of logic problems, complete with answers in the back.
It's called "How Would You Move Mount Fuji" and it's on amazon for pretty cheap.
http://www.amazon.com/gp/offer-listing/0316919160/ref=dp_olp_used?ie=UTF8&condition=used
I've just completed a round of interviews, where I use a three or four stock 'simple' C# code fragments that the interviewee will look through and attempt to explain what the expected result will be. In each case the code sample is no more than ten lines of clearly-formatted code that utilises basic C# skills (inheritance, generics, anonymous delegates); also in each case there will be a 'gotcha' - but like others have stated, I don't put these in to be spiteful, they're there because I want to see how the candidate reacts when confronted with something that doesn't work as expected.
We had a candidate recently that had sailed through the first part of his interview; impressive CV, was apparently the Lead Developer of a team of 10 and had been developing code in C# since 1.0; yet apparently had no idea what "Console.WriteLine()" did (nor could he even hazard a guess), nor could he even begin to cope with the tiny anonymous delegate example.
Another candidate was self-effacing, and didn't know how to grade herself as a developer - she'd had less experience than the former candidate yet she sailed through the code samples, fell for a couple of the 'gotchas' but asked the right questions to get the correct conclusions and genuinely learnt from the experience. Needless to say, she was hired.
If you're claiming domain-specific knowledge (like XML) you should expect to be asked specific (and sometimes hard) questions about that domain; if I'm interviewing a senior ASP.NET developer and they've got no idea about HttpModules or HttpHandlers (like some recent interviewees) then alarm bells start to ring.