C# EventArgs in Visual Studio 2012 vs Visual Studio 2010

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi C# Connoisseurs,
The following code works in Visual Studio 2012, however in Visual Studio 2010, it doesnt compile:
The type StartEventArgs cannot be used as type parameter TEventArgs in the generic type or method System.EventHandler<TEventArgs>. There is no implicit reference conversion from StartEventArgs to System.EventArgs.
Can you please explain this phenomenon? I mean in Visual Studio 2010, you got to extend from EventArgs "public sealed class StartEventArgs : System.EventArgs, why?
<pre class="prettyprint using System;

public sealed class StartEventArgs
{
}

class Program
{
public event EventHandler&lt;StartEventArgs&gt; Start;

public void Print()
{
Console.WriteLine(&quot;Fine!&quot;);
}

static void Main()
{
Program prgm = new Program();
prgm.Print();
Console.ReadKey();
}
}
[/code]
Thanks<br/>

View the full article
 
Back
Top