WinFX Trivia Quiz Answer: What are the most used APIs in the BCL?

Great guesses on my recent quiz...   Here are the answers... Now a question for you -- any theories on why this APIs are so popular? 

1,System.Type.GetTypeFromHandle(System.RuntimeTypeHandle handle),15399
2,System.Byte[,,].Set(Int32 ,Int32 ,Int32 ,Byte ),13122
4,System.Resources.ResourceManager.GetObject(System.String name),2845
5,System.Byte[,].Set(Int32 ,Int32 ,Byte ),2692
6,System.Text.StringBuilder.Append(System.String value),2588
10,System.Collections.ArrayList.Add(System.Object value),2049

Comments (14)

  1. Spong says:

    From the look of them, because they’re used in interop scenarios, and the BCL has to tie in with the platform at some layer?

  2. Ingo Rammer says:

    Hmmmm … why do you need so many handle-to-type-conversions and byte ops? Unmanaged code? DirectX? Wild guesses ….


  3. Panos Theofanopoulos says:



    75 bugs or perhaps some lazy coders ?

  4. Panos Theofanopoulos says:

    Ingo :

    the typeof(sometype) expression compiles to System.Type.GetTypeFromHandle( sometype metadata token )

  5. Brad Abrams says:

    Yup — Panos got number one… C#’s typeof and VB GetType() complile down to a call to Type.GetTypeFromHandle…

    I am not sure MoveNext and the Current property are a product of lazy programmers… I bet most of you use them in nearly every program..

  6. Andreas Häber says:

    Doesn’t foreach compile to be System.Collections.IEnumerator.MoveNext() and System.Collections.IEnumerator.get_Current() calls?

    The difference would then be that foreach uses MoveNext() to check if it should call get_Current(). So, to be more clear, if MoveNext() returns false then you won’t call get_Current().

  7. Panos Theofanopoulos says:

    Brad :

    I am pointing that they are different, a typical foreach has one call to MoveNext() and one call to get_Current, so since MoveNext calls are more than get_Current

    1) someone is using MoveNext() just to count the collection’s elements (lazy)

    2) is not using the Current of IEnumerator but something else (bug)

  8. Corrado Cavalli says:

    System.Resources.ResourceManager.GetObject(System.String name)

    Maybe because it is the code generated when you localize a windows form?

  9. Eric says:

    There’d always be one fewer get_Current call per use of foreach because MoveNext will advance to the element past the end, then return false, preventing get_Current from being called.

  10. Andreas Häber says:

    Eric: yeah, that was a better way to say this then my attempt above 🙂

  11. Ken says:

    Eric: I think the count was the number of call sites, not the number of calls in an actual run of a program.

  12. Brad Abrams says:

    Yes, this is a static code analysis tool…

Skip to main content