<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sharpreflections.net &#187; Quiz</title>
	<atom:link href="http://blog.sharpreflections.net/category/quiz/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sharpreflections.net</link>
	<description>Thoughts about .Net, programming and other more important stuffs.</description>
	<lastBuildDate>Fri, 20 Nov 2009 00:24:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quiz #3</title>
		<link>http://blog.sharpreflections.net/2008/02/27/quiz-3/</link>
		<comments>http://blog.sharpreflections.net/2008/02/27/quiz-3/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 23:05:25 +0000</pubDate>
		<dc:creator>matteosp</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://sharpreflections.wordpress.com/2008/02/27/quiz-3/</guid>
		<description><![CDATA[Take the following snippet:
public class Foo
{
  // add code
  public static int MethodOne() { return 0; }
  public static string MethodTwo() { return string.Empty; }
}

public class Program
{
  public static void Main()
  {
    try { Foo.MethodOne(); }
    catch (Exception ex) { Console.WriteLine(ex.Message); }

   [...]]]></description>
			<content:encoded><![CDATA[<p>Take the following snippet:</p>
<pre><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Foo
{
  <span style="color:#008000;">// add code</span>
  <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">int</span> MethodOne() { <span style="color:#0000ff;">return</span> 0; }
  <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">string</span> MethodTwo() { <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">string</span>.Empty; }
}

<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Program
{
  <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main()
  {
    <span style="color:#0000ff;">try</span> { Foo.MethodOne(); }
    <span style="color:#0000ff;">catch</span> (Exception ex) { Console.WriteLine(ex.Message); }

    <span style="color:#0000ff;">try</span> { Foo.MethodTwo(); }
    <span style="color:#0000ff;">catch</span> (Exception ex) { Console.WriteLine(ex.Message); }
  }
}</pre>
<p>and add the code necessary (you cannot modify in any way MethodOne and MethodTwo) to make both method invocation throw an exception.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharpreflections.net/2008/02/27/quiz-3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Quiz #2</title>
		<link>http://blog.sharpreflections.net/2007/04/11/quiz-2/</link>
		<comments>http://blog.sharpreflections.net/2007/04/11/quiz-2/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 19:42:51 +0000</pubDate>
		<dc:creator>matteosp</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://sharpreflections.wordpress.com/2007/04/11/quiz-2/</guid>
		<description><![CDATA[Look at the following snippet:
public class Foo
{
    protected Foo() {}
}

public class Var : Foo
{
    Var(): base() {}

    void Main()
    {
        Foo foo = new Foo();
    }
}
Now tell me if it can be successfully [...]]]></description>
			<content:encoded><![CDATA[<p>Look at the following snippet:</p>
<pre><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Foo
{
    <span style="color:#0000ff;">protected</span> Foo() {}
}

<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Var : Foo
{
    Var(): <span style="color:#0000ff;">base</span>() {}

    <span style="color:#0000ff;">void</span> Main()
    {
        Foo foo = <span style="color:#0000ff;">new</span> Foo();
    }
}</pre>
<p>Now tell me if it can be successfully compiled:</p>
<ol>
<li>both in 1.1 and 2.0</li>
<li>only in 1.1</li>
<li>only in 2.0</li>
<li>neither in 1.1 nor in 2.0</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharpreflections.net/2007/04/11/quiz-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quiz #1</title>
		<link>http://blog.sharpreflections.net/2007/03/15/quiz-1/</link>
		<comments>http://blog.sharpreflections.net/2007/03/15/quiz-1/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 20:19:25 +0000</pubDate>
		<dc:creator>matteosp</dc:creator>
				<category><![CDATA[.Net Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://sharpreflections.wordpress.com/2007/03/15/quiz-1/</guid>
		<description><![CDATA[Modify this apparently thread-safe event raiser in such a way it becomes truly thread-safe without changing signature nor implementation.
protected void OnMyEvent(MyEventArg e)
{
   MyEventHandler handler = MyEvent;

   if (handler != null)
      handler (this, e);
}
Inspired by this post by Pierre Greborio.
]]></description>
			<content:encoded><![CDATA[<p>Modify this <strong>apparently</strong> thread-safe event raiser in such a way it becomes <strong>truly</strong> thread-safe <font color="#ff0000">without changing signature nor implementation</font>.</p>
<pre><span style="color:#0000ff;">protected</span> <span style="color:#0000ff;">void</span> OnMyEvent(MyEventArg e)
{
   MyEventHandler handler = MyEvent;

   <span style="color:#0000ff;">if</span> (handler != <span style="color:#0000ff;">null</span>)
      handler (<span style="color:#0000ff;">this</span>, e);
}</pre>
<p>Inspired by <a href="http://blogs.ugidotnet.org/pierregreborio/archive/2007/01/19/67679.aspx" title="Lanciare l'evento in modo sicuro" target="_blank" rel="Lanciare l'evento in modo sicuro">this post</a> by <a href="http://blogs.ugidotnet.org/pierregreborio/" title="UGbLog di Pierre Greborio" target="_blank">Pierre Greborio</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharpreflections.net/2007/03/15/quiz-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quiz Sharp #0</title>
		<link>http://blog.sharpreflections.net/2007/03/09/quiz-sharp-1/</link>
		<comments>http://blog.sharpreflections.net/2007/03/09/quiz-sharp-1/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 17:58:37 +0000</pubDate>
		<dc:creator>matteosp</dc:creator>
				<category><![CDATA[.Net Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Quiz]]></category>

		<guid isPermaLink="false">http://sharpreflections.wordpress.com/2007/03/09/quiz-sharp-1/</guid>
		<description><![CDATA[This is my first quiz, and is the result of a beatiful and long chat with my good friend Adrian Florea. Here the Italian version on his blog.
Look at this snippet:
struct Foo
{
	public static implicit operator bool(Foo value)
	{
		return value != null;
	}
}

static void Main(string[] args)
{
	if (new Foo())
	{
		Console.WriteLine("Hello word!");
	}
}
What will you get? And, first of all, why?
a) nothing
b) [...]]]></description>
			<content:encoded><![CDATA[<p>This is my first quiz, and is the result of a beatiful and long chat with my good friend <a href="http://blogs.ugidotnet.org/adrian/" target="_blank">Adrian Florea</a>. <a href="http://blogs.ugidotnet.org/adrian/archive/2007/03/09/72692.aspx" target="_blank">Here</a> the Italian version on his blog.</p>
<p>Look at this snippet:</p>
<pre><span style="color:#0000ff;">struct</span> Foo
{
	<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">implicit</span> <span style="color:#0000ff;">operator</span> <span style="color:#0000ff;">bool</span>(Foo <span style="color:#0000ff;">value</span>)
	{
		<span style="color:#0000ff;">return</span> <span style="color:#0000ff;">value</span> != <span style="color:#0000ff;">null</span>;
	}
}

<span style="color:#0000ff;">static</span> <span style="color:#0000ff;">void</span> Main(<span style="color:#0000ff;">string</span>[] args)
{
	<span style="color:#0000ff;">if</span> (<span style="color:#0000ff;">new</span> Foo())
	{
		Console.WriteLine("<span style="color:#8b0000;">Hello word!</span>");
	}
}</pre>
<p>What will you get? And, first of all, why?</p>
<p>a) nothing</p>
<p>b) &#8220;Hello word!&#8221;</p>
<p>c) a compiler error</p>
<p>d) a runtime error</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharpreflections.net/2007/03/09/quiz-sharp-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
