I did warn you that these would be trivial. Here are the answers:
1) How many loop constructs does C# have, and what are they?
for, foreach, while, do
Or, perhaps, that’s only two, given that for and foreach and while and do are variants of each other.
2) What is the difference between “ref” and “out”?
From the runtime perspective – and the perspective of other languages – there is no difference between the two – they are both “pass by reference”.
In C#, “out” means:
C# and the Runtime
3) What does
Why would you use it?
This gives a name to an indexer. Because the C# syntax never shows the name, it doesn’t matter to C# code, but it does to VB code. By default, the indexer is named “Items”. If you were adding an indexer for a string, you might want to call it “Characters”. Or, perhaps “DramatisPersona”…
C# and other languages
4) You are a troublemaker in a group of Java and C# programmers. What should you say?
Checked exceptions have been – and still are – one of the hot topics between the two communities, with lots of strong opinions.
I like these resources:
The Trouble with Checked Exceptions (Hejlsberg)
My opinion is that checked exceptions address an issue that isn’t high on the list of issues that need to be addressed, and impose a significant burden (both in language complexity and in programmer busy work) while doing so.
5) How many conference rooms has the C# language design team met in over the years?
One, a small conference room in the second floor of building 42.
Okay, that’s not strictly correct – there been a few meetings elsewhere – but at least 95% of the meetings have been in that room.
How were you supposed to know this? Well, Anders has said it publicly at least once, and I think he did in this video (well worth it even if he didn’t say it in that one).
6) Which of the following are not spare-time pursuits of mine?
All MSDN columns include an author bio at the bottom (“Reginald Codesqueezer is an evangelist in the programmer kitchen accessories group at Microsoft, where he is working on the release of CodeWok 2.0.”)
Way back, when .NET was young, I wrote a chapter for a .NET book about the C# language (sometime shortly after my book was published). I don’t remember the book or really what the chapter was about, but I do know that the publisher asked me for a bio, I forget, the publisher asked me again, and I sent off something that I thought might be funny, which showed up in the book.
Which leads us to the answer, easily verified with a search engine (“eric gunnerson cat juggling“), which is that these are all spare time pursuits of mine, making this a trick question.
When I started writing my MSDN column, I had a pretty blah bio, but after a while, I wondered how much attention my editor was paying to what I wrote, so for the last few columns, I started changing the last line of my bio.
The bio in my current book ends with, “In his spare time, he enjoys skiing, cycling, home improvement, microcontroller-based holiday decorations, pinball, Halo2, and writing about himself in the third person”, which my Apress editor really liked.
7) What does typing the following do:
b) Print an error message
c) Compile the latest version of my multi-player version of SpaceWar!
The C# team had a problem. Every day, posts were showing up on our internal discussion group saying, “When I try to compile this program, it’s complaining that it can’t find this class, but I have a using statement”. Or, they would say, “this code works when I compile it in Visual Studio, but it doesn’t work from the command line”.
The problem was that the compiler only referenced mscorlib.dll and system.dll by default, and you really can’t do anything of interest without referencing other assemblies. It didn’t show up in VS because when you create a project in VS, it adds a default set of assembly references to the project.
So, we needed a way to fix that. We considered some elegant solutions so that all compiles wouldn’t have to pay the price of opening a bunch of assemblies that weren’t necessary, but it turned out that the perf cost wasn’t significant.
So, we decided to add a response file. The concept of response files wasn’t original – VC++ has supported them for quite a while – but I do think the concept of having a default response file was new. If you find csc.exe on your system (mine lives at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727), you’ll find that there’s a csc.rsp file there that lists all the “default” assemblies. You can edit that file if you want, or you can put your own csc.rsp file in a directory.
Interestingly, because the response file is just used as input to the compiler, you can put filenames in there too, which means the correct answers to the question are “b” or “c”.
The addition of the default response file fixed the command-line problem, but led to the reverse problem, since VS (for perf reasons, IIRC) didn’t reference as many assemblies automatically as the command-line compiler did.
SpaceWar! rocked, BTW.
8) What was the name of .NET before it became .NET?
Next Generation Windows Services (NGWS), pronounced “Nugh-was” (though rarely pronounced at all).
This marketing name was replaced by the elegant and much-easier-to-say “.NET”, which would go on to confuse millions of customers worldwide.
9) Current Visual C# PUM Scott Wiltamuth was the PM for the C# language during the first version, but often worked remotely because of a long commute. How long was his commute?
Around 8 hours – 6 hours on the plane, and an hour at either end.
Scott worked remotely from Hawaii, and did a pretty remarkable job doing so.