Share via


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!

Comments

  • Anonymous
    May 03, 2006
  1. Politics.
  • Anonymous
    May 03, 2006
  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
  • Anonymous
    May 03, 2006
    12)
    Change string to stringbuilder, strings are immutable.

    13)
    Db (D flat :D)
  • Anonymous
    May 03, 2006
    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.
  • Anonymous
    May 03, 2006
  1. Finalization
    8) Structs
    9) Andy the C# Mascot
    14) July 11 2000 in Orlando, FL.  
  • Anonymous
    May 03, 2006
    On #1, I meant different from types like int or bool

    Eric
  • Anonymous
    May 03, 2006
  1. Properties
  • Anonymous
    May 03, 2006
    "10) What is my most useless computer-related skill?"

    The ability to press SysRq without looking.
  • Anonymous
    May 03, 2006
    The comment has been removed
  • Anonymous
    May 03, 2006
    #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".
  • Anonymous
    May 03, 2006
  1. It's not natively implemented in the JIT. (I guess). You could make your own.
  • Anonymous
    May 03, 2006
  1. Raw computing performance vs. good memory managment
  • Anonymous
    May 03, 2006
    #7) Ask whether multiple inheritance is a good thing :)
  • Anonymous
    May 03, 2006
  1. Partial template specialisation and template meta programming.
  • Anonymous
    May 03, 2006
    #2 has always annoyed me.  What if I want my structs to have a default of "1" in a certain field.  Arg.
  • Anonymous
    May 03, 2006
    #2 has always annoyed me.  What if I want my structs to have a default of "1" in a certain field.  Arg.
  • Anonymous
    May 03, 2006
  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
  • Anonymous
    May 03, 2006
  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).
  • Anonymous
    May 03, 2006
    Oh, and I believe that #13 is Safe-C, but I also think that Safe-C is now another project unrelated to C#.
  • Anonymous
    May 03, 2006
  1. Change the "long" to "int" (LONG is 4 bytes in Win32)