Welcome to MSDN Blogs Sign in | Join | Help

C# Trivia Test - Part 11

Here we go, with the last installment of the series...

Language Details

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

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

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

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

C# and the Runtime

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

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?

Real Triva

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

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

10) What is my most useless computer-related skill? Hint: It's not my rudimentary knowledge of 6502 assembler.

Power Users

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

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>?

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

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!

Published Wednesday, May 03, 2006 8:29 AM by ericgu
Filed under: ,

Comments

Wednesday, May 03, 2006 12:12 PM by oldnewthing

# re: C# Trivia Test - Part 11

7) Politics.
Wednesday, May 03, 2006 12:33 PM by Damien Guard

# re: C# Trivia Test - Part 11

1.  Different from what other types?
2. A default constructor.  Because structs need to be initialized quickly especially for use in arrays etc.
3. out is a keyword, [out] is an identifier
4. UInt64.
5. IEnumerable to get an IEnumerator.  In .NET 2.0 it uses IEnumerable<T> to get an IEnumerator<T>.
7. Garbage collection.
11. To give the debugger something to tie up with source lines where there are no actual executable code.
14. 2000?

[)amien
Wednesday, May 03, 2006 12:42 PM by Sachin

# re: C# Trivia Test - Part 11

12)
Change string to stringbuilder, strings are immutable.

13)
Db (D flat :D)
Wednesday, May 03, 2006 1:03 PM by Peter Ritchie

# re: C# Trivia Test - Part 11

Raymond: or 7) religion ;-)

Decimal: const Decimal is not supported by IL (like other value types) and C# will convert to static readonly Decimal; which also means the compiler will convert its use to a literal and never reference the original static readonly field again.  If the const Decimal is a public field of a class in a referenced assembly, any changes to the const Decimal in that referenced assembly will not be used unless the client assembly is recompiled.  Other value types do not do this.
Wednesday, May 03, 2006 1:10 PM by Ricky Dhatt

# re: C# Trivia Test - Part 11

7) Finalization
8) Structs
9) Andy the C# Mascot
14) July 11 2000 in Orlando, FL.  
Wednesday, May 03, 2006 1:19 PM by ericgu

# re: C# Trivia Test - Part 11

On #1, I meant different from types like int or bool

Eric
Wednesday, May 03, 2006 1:28 PM by Jeremy D

# re: C# Trivia Test - Part 11

7) Properties
Wednesday, May 03, 2006 2:10 PM by Jeffrey L. Whitledge

# re: C# Trivia Test - Part 11

"10) What is my most useless computer-related skill?"

The ability to press SysRq without looking.
Wednesday, May 03, 2006 2:42 PM by Matt

# re: C# Trivia Test - Part 11

6) Syste,.AttributeUsageAttribute
7) deterministinc finalization :)

oh and 1) it's horrifically bloody slow?

technically every integral and floating point number can have the operators +,-,* and / applied to them where the result is automatically the most precise of the two available.

decimal breaks this since it won't play nice with doubles and floats (as they won't for a neat approximate superset)

Technically this doesn't cover char or bool though.

Just found it (Ithink) it's the only value type in the int,char,bool,integrals,floats which has instance constructor(s) such as new Decimal(double)
Wednesday, May 03, 2006 2:44 PM by JamesCurran

# re: C# Trivia Test - Part 11

#12 I have no real idea (Sachin's sound good), but it does remind me of my experience solving problems on a C++ newsgroup.

Every now & then, someone will post a problem, adding that the reason they need help is because, while it will fail when the app is run, when they step through it in a debugger, it works fine.   Eventually, I learned to respond "I don't need to see the code -- you are overunning a local array".
Wednesday, May 03, 2006 3:19 PM by Bas Westerbaan

# re: C# Trivia Test - Part 11

1. It's not natively implemented in the JIT. (I guess). You could make your own.
Wednesday, May 03, 2006 3:23 PM by Bas Westerbaan

# re: C# Trivia Test - Part 11

7. Raw computing performance vs. good memory managment
Wednesday, May 03, 2006 3:23 PM by Eric Wilson

# re: C# Trivia Test - Part 11

#7) Ask whether multiple inheritance is a good thing :)
Wednesday, May 03, 2006 4:14 PM by Richard

# re: C# Trivia Test - Part 11

7. Partial template specialisation and template meta programming.
Wednesday, May 03, 2006 7:13 PM by Miral

# re: C# Trivia Test - Part 11

#2 has always annoyed me.  What if I *want* my structs to have a default of "1" in a certain field.  Arg.
Wednesday, May 03, 2006 7:13 PM by Miral

# re: C# Trivia Test - Part 11

#2 has always annoyed me.  What if I *want* my structs to have a default of "1" in a certain field.  Arg.
Wednesday, May 03, 2006 7:53 PM by ben

# re: C# Trivia Test - Part 11

1) not a native type
2) parameterless constructors, I dont know why
3) ??
4) System.UInt64
5) IEnumerable & IEnumerator and IEnumerable<T> IEnumerator<T>
6) ??
7) Multiple inheritance
8 - 12) ??
13) Safe-C
14) PDC 98
Wednesday, May 03, 2006 9:51 PM by TheMuuj

# re: C# Trivia Test - Part 11

1) decimal is the only C# native type that is not a primitive type, and as such the compiler handles constants using a readonly field and an attribute with the binary form of the value.  Also, operators are provided by overloads (where as VB uses its own implementation of those operators, even in .NET 2 I believe).
2) Default constructors cannot be declared because creating an array of structs would not call this constructor for performance reasons
3) [Out] only applys to P/Invoke, I believe, and is for use with both references AND pointers
4) In .NET 2.0: System.UInt64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
5) If possible, foreach tries to not use any interface (it uses static duck typing in order to prevent boxing), save for IDisposable.  However, it does use the IEnumerable/IEnumerator pattern (and the generic versions in .NET)
6) AssemblyUsageAttribute (which, in a chicken-egg twist, is applied to itself)
7) Pretty much anything, but especially Templates vs. Generics and/or runtime performance
8) ?? When the spec declares bankruptcy?
9) ??
10) ?? typing on an upside-down Dvorak keyboard?
11) To allow breakpoints on lines of code that don't actually do anything (unless you're talking about release mode, in which case I have no idea since alignment is probably not a big issue)
12) I'm always saying "int" to "IntPtr", but that problem will only show up on 64-bit machines (too many people adapt the old VB6 API calls, which is WRONG WRONG WRONG since VB6 was 32-bit).
Wednesday, May 03, 2006 9:52 PM by Matthew W. Jackson

# re: C# Trivia Test - Part 11

Oh, and I believe that #13 is Safe-C, but I also think that Safe-C is now another project unrelated to C#.
Thursday, May 04, 2006 4:02 AM by Stu Smith

# re: C# Trivia Test - Part 11

12) Change the "long" to "int" (LONG is 4 bytes in Win32)
Friday, May 05, 2006 12:28 AM by dhananjay singh

# re: C# Trivia Test - Part 11

2) Default constructor is not legal because in struct you can't do instance field initialization. So runtime need default constructor to initialize all instance fields to their default value.
struct MyStrstrcut
{
int i=10 //illegal
}

7)C++ and C# nearly share all feature then why not just say
How java is sucking on exception ;)

12) Change CALL to CALLVIRT in IL code.
Friday, May 05, 2006 12:30 AM by dhananjay singh

# re: C# Trivia Test - Part 11

Ahh I forget this one first one
1)because of its size it requir 2 read instruction for processor ;0)
Friday, May 05, 2006 12:32 AM by dhananjay singh (dhananjay123@hotmail.com)

# re: C# Trivia Test - Part 11

1)Decimal require 2 read instruction
2) Default constructor is not legal because in struct you can't do instance field initialization. So runtime need default constructor to initialize all instance fields to their default value.
struct MyStrstrcut
{
int i=10 //illegal
}

7)C++ and C# nearly share all feature then why not just say
How java is sucking on exception ;)

12) Change CALL to CALLVIRT in IL code.
Friday, May 05, 2006 12:32 AM by tp

# re: C# Trivia Test - Part 11

tp
Saturday, May 06, 2006 8:27 AM by Sheva

# C# Trivia Test

Sunday, May 07, 2006 5:50 AM by Sheva

# C# Trivia Test

Monday, May 08, 2006 7:01 PM by Eric Gunnerson's C# Compendium

# C# Trivia Test Answers - Part 11

C# Trivia Test - Part 11




(My initial set of responses vanished into the bit bucket due to the...

# Eric Gunnerson s C Compendium C Trivia Test Part 11 | Green Tea Fat Burner

New Comments to this post are disabled
 
Page view tracker