C# Trivia Test Q&A

转载 2006年05月28日 23:08:00

C# Trivia Test 

Language Details

1) How is decimal different from other C# types?

Decimal is from Mars, int is from Venus. Or perhaps it's the other way around.

Try the following experiment:

a) Write a short C# program that adds two integers.

b) Look at the generated IL.

c) Do the same thing with two decimals.

The difference is that decimal is implemented as a user-defined type, while types like int have specific opcodes devoted to them.

2) What kind of constructor is not legal on structs? Why?

A default constructor. Why? Because in some interop scenarios, the runtime needs to create structs, but it has no way of running any managed code.

At least that's what I heard...

3) What’s the difference between “out” and “[out]”?

One has brackets around it, the other doesn't.

I'm surprised nobody got that one.

If you're looking for another difference, "out" is all about definite assignment, and lets you skip initializing a variable that is passed by reference, while "[out]" is a directive telling the marshaler what to do.

4) When you write ulong, what does the runtime see?

Throatwarbler Mangrove.

Or, perhaps it's System.UInt64. Definitely one of those.

(extra credit: Discuss, without any websearches, the relation of the above reference to naval ambitions.)

C# and the Runtime

5) What interfaces does foreach use in C# 1.1? What about 2.0?

IEnumerable, IEnumerator. IEnumerable<T>, IEnumerator<T>.

Extra credit: Why is the generic version of this so much cooler?

6) What is the name of the attribute that controls the usage of an attribute?


C# and other Languages

7) C# and C++ programmers are at a party (okay, it's a really a user-group meeting). The mood is too nice. What topic do you bring up?

Well, I would bring up deterministic finalization, otherwise know as the "why can't you run my destructor when my variable goes out of scope?" question.

Real Trivia

8) What is chapter 11 of the C# Language spec?

There are two answers to this question. One is "structs", the other is something I'm too lazy to look up right now.

(extra credit: explain why there are two answers.)

9) For a while, C# had a mascot. What was his name? Extra points for his full name.

His name is Andy. No credible evidence has been found to document his first name, but some sources list it as "Angry".
10) What is my most useless computer-related skill? Hint: It's not my rudimentary knowledge of 6502 assembler.

Back in my formative years, I got up extra early in the morning to back up my university's data center. Months of careful practice led to me mastering the art of mounting a backup tape with one hand - and this wasn't just the "put it on the machine with one hand", it was the full "pop off the outer tape ring, put it on the spindle and hit the load button faster than you can say "Bob's your uncle"".

And then, with more months of practice, I progressed to to a new level, when I was able to do that with both hands simultaneously.

It wasn't very useful 2x years ago, so it's certainly not useful now...

Power Users

11) Why does the compiler put "nop" (ie no op) instructions in my IL?

On some systems, you can encounter synchronization issues if one process runs significantly faster than another. The compiler therefore contains an analysis engine that looks at your code, and if it is especially fast, inserts some nop instructions to slow the speed to down to a safe level.

So, consider this a compliment by the compiler about the code that you wrote.

Or, perhaps it has something to do with giving the debugger a place to put a breakpoint. I forget.

12) I have an extraordinary power. I can diagnose problems with P/Invoke statement psychicly. You're having a problem, you come to me, and I say, "Change the <x> in your definition to <y>". And I'm right, about 83% of the time.

What is <x> and what is <y>?

<x> = "messed-up word"
<y> = "the right word"


<x> = "long"
<y> = "int"

In C++, "long" means 4 bytes. In C#, it means 8 bytes. Using long when you mean int makes the runtime angry.

Ancient History

13) Which one of these was a C# codename before disclosure:
a) Awesome!
b) C+++-
c) C-Sure
d) Safe-C
e) C how quick I can write code now!
f) The C clearly system

"d" is the correct answer, and is one of two names used on C#.

I'm sworn to never reveal the other codename. I've thought many times about writing about it any way, because it would make a great story. I've even started to write a post.

But in the end, I decided that doing that wouldn't be cool.

14) C# was first talked about widely at a PDC. What year was it? Where was it held, and how hot was it?
a) 98 degrees
b) Hotter than a jalapeno in a heat wave
c) Hot enough to make your palms sweat at 7:00 AM
d) Hot enough to lose 20 pounds in 20 days, ask me how!

Reliable sources suggest that the year was 2000, and that it was held in a hotel steam bath. Others suggest that it was held in Orlando, and further others maintain that there is no practical difference between the two, except that in the hotel steam bath you may ask the attendent to fetch you a drink.

As for how hot it was, all four answers are correct, though the first one is a bit of a underestimation.

Why Orlando in July? Well, unless you know exactly when your software will be done, it's hard to book early enough to get a nicer venue.


根据《Python 游戏编程入门》第三章的内容,通过一个问答小游戏对python的基本使用进行了了解。由于书上的面向对象的实现方法没有跑起来,于是用面向过程的思想实现了下。下面将一些细节部分记录一下。...
  • awawfwfw
  • awawfwfw
  • 2015年06月28日 00:08
  • 599


掌握知识点: I/O、 数据 、字体1.Python数据类型 2.获取用户输入 3.处理异常 4.Mad Lib 游戏 5.操作二进制文件 6.Trivia游戏==============...
  • LSYtop
  • LSYtop
  • 2016年06月25日 09:13
  • 740


希望日方对障害详细说明: 日本語:Lxxで/障害xx番目、「○○○」について、具体的に説明していただけませんか。中国語:在第xx行/障碍号xx,关于「○○○」,是否能具体说明一下呢。  日方所...
  • dhy270498872
  • dhy270498872
  • 2012年11月23日 10:37
  • 1766


2007年10月06日 21:37:00 设计模式简介(第5章)复习题简答题1) 设计模式思想应该归功于谁?建筑师Christopher Alexander在20世纪70年代末期...
  • softart
  • softart
  • 2007年10月27日 09:31
  • 603


性能 Q1:在整体的性能消耗上,CPU和GPU各占一半合理吗?如果不是,各占多少为好?还是说需要根据机型来看?其次,我如何知道游戏在手机上的GPU消耗?Profiler是看不到的,有工具推荐吗?...
  • e295166319
  • e295166319
  • 2017年04月01日 14:24
  • 259

[6] Word Q&A

Q&A 保存错了怎么办,恢复之前的版本 没有退出的时候,可以撤销ctrl+z,退出则要设置,文件-选项-高级,始终创建备份副本,文件-选项-保存,时间和位置以及保存频率如何显示所有字符? 文件...
  • yangfeng2014
  • yangfeng2014
  • 2016年04月13日 08:04
  • 270


Background 1. mvapich2-1.9a rpm -qa | grep mvapich2 wget http://mvapich.cse.ohio-state.edu/downlo...
  • vanderong
  • vanderong
  • 2012年10月01日 10:39
  • 2605


问候语:   一般情况下,问候语可以省略,即使是用,也一般会抱着打扰和抱歉的语气去问或回答,所以在开头部分用得比较多的为: すみません 中文:不好意思/打扰一下/对不起(使用上面相对比较多)。...
  • dhy270498872
  • dhy270498872
  • 2012年11月23日 10:38
  • 735


我正在学习 Microsoft .NET 框架,不太理解控件和组件之间的差别。我知道这些术语可以互用,但什么时候从 Control 派生,什么时候从 Component 派生呢?   好问题!简...
  • kingmax54212008
  • kingmax54212008
  • 2012年04月15日 17:08
  • 706

Q&A handbook

1. 矩阵求导? 2. 矩阵的L1范数? 矩阵的L1范数是矩阵的列的绝对值之和的最大值。 证明: Let’s denote the columns of AAA by A1,…,AnA1...
  • ibunny
  • ibunny
  • 2018年03月01日 10:30
  • 31
您举报文章:C# Trivia Test Q&A