Needs Improvement

Colin Coller's Blog
Posts: 62 | Comments: 156 | TrackBacks: ?

January 26, 2005

C# and .NET quizzes

I've been quizzing my team on C# and .NET for the past few weeks to expose everyone to features they don't use regularly (or ever). The quizzes are optional and unscored, the only rewards are peer recognition and learning, and using VS.NET, MSDN, and Google to answer the questions is encouraged. The questions are a mix of "how would you", "would it compile", and "write code to", and most questions include compilable skeleton code.

Yesterday's quiz was on enumerability:

Implement a class named Alphabet that, when iterated through 
using foreach, returns all of the letters of the alphabet.

using System;
using System.Collections;

class PrintAlphabet
{
	static void Main()
	{
		Alphabet alphabet = new Alphabet();
		foreach ( char letter in alphabet )
		{
			Console.WriteLine( letter );
		}
	}
}

class Alphabet /* implement me */
{
	/* implement me */
}

We all know how to use foreach, but most of us don't know how foreach works, how to make classes enumerable, or if such a thing is possible. Having to implement Alphabet means looking behind the curtain, seeing that it isn't magic, and learning how it all works.

I've been writing the quizzes myself, but I'm wondering if there aren't already blogs, sites, or books dedicated to C# and .NET quizzes like this. I know Brad Abrams posts quizzes regularly, but they're more advanced than mine, and many of them are on C# 2.0. Do you have any suggestions? Have you worked for a company that did quizzes like this?

Thanks,

Colin

01:12 PM | Colin

TrackBacks

# C# .NET Quizzes

03:46 PM | you've been HAACKED

# Visual Studio Hacks: Add-in, Tool, and Macro Authors

03:11 PM | .Avery Blog

# ringtones ?????????¦???????

10:57 AM | ringtones

# freeringtones ?????????¦???????

03:18 AM | freeringtones

# cheaptickets ?????????¦???????

07:33 AM | cheaptickets

# vlJVNkfLm kzoIvcbh fsHbtEYdB [URL=http://vwkynffciahs.com/]GVXvoLFWFrds[/URL]

04:54 AM | bOKyMKpzm

# americanairlines ?????????¦???????

09:09 AM | americanairlines

Comments

# RE: C# and .NET quizzes

//I sometimes do quizzes like this at work. Here's my quick and dirty answer.
//I know it's probably not what you're looking for, but I like to give the sneaky
//answer to quizzes.

public class Alphabet : IEnumerable
{
public IEnumerator GetEnumerator()
{
return "abcdefghijklmnopqrstuvwxyz".GetEnumerator();
}
}

03:31 PM | Haacked

# RE: C# and .NET quizzes

I should point out that as a real developer, the answer should be "well which alphabet(s) must I support". My solution is not localizable.

03:37 PM | Haacked

# RE: C# and .NET quizzes

Phil:

Good points.

The quiz actually said "Wrapping an Array or ArrayList of letters is cheating." I wanted to make sure everyone implemented IEnumerator and IEnumerable without saying "You must implement IEnumerator and IEnumerable." and giving the whole thing away. I see I shouldn't have cut that line from my post. :)

I thought about saying which alphabet to use and talking about globalization issues, but the point of the quiz was to learn about enumerability, and that wouldn't have helped.

Who writes the quizzes you do at work?

Colin

04:28 PM | Colin

# RE: C# and .NET quizzes

Ha, though technically I didn't write an array, I wrote a string. ;) (yeah, you might consider it an array but I don't think it's implemented that way).

I write the quizzes. I do it occasionally when I feel like it. Very informal. I usually post them on my blog.

10:35 AM | Haacked

# RE: C# and .NET quizzes

> I'm wondering if there aren't already blogs, sites, or books dedicated to C# and .NET quizzes like this


Hi Colin,


I have 2 categories on my blog that you could enjoy:

Quiz Sharp: http://blogs.ugidotnet.org/adrian/category/272.aspx?Show=All

with multi-choice C# questions and

Test Sharp: http://blogs.ugidotnet.org/adrian/category/282.aspx?Show=All

with problem-like .NET questions.


Adrian

02:38 PM | Adrian Florea

# RE: C# and .NET quizzes

Adrian:

My Italian is a bit rusty, but il vostro blog è molto, molto utile. Grazie!

Colin

02:56 PM | Colin