<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - basic C# question</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - basic C# question</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Wed, 22 May 2013 08:04:17 GMT</pubDate>
	<lastBuildDate>Wed, 22 May 2013 08:04:17 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>12</c9:totalResults>
	<c9:pageCount>-12</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>Hi guys, it is my first time posting here in channel9, so please if I made a mistake, please tell me.<br /><br />I am currentlly learning C#, but I couldn`t understand the Event and the Event Handler, can some one help me with it? I have read the documentation in the library of the C# express edition but I didn't managed to understand it very well.
<br /><br />And thank you in advance.<br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/257232#257232</link>
		<pubDate>Sun, 26 Aug 2007 19:08:13 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/257232#257232</guid>
		<dc:creator>katana_234</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/katana_234/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>The even is an implementation of the <a href="http://en.wikipedia.org/wiki/Observer_pattern">
observer design pattern</a>. The idea is that you can register for something to happen and once it happens you get informed about that.<br /><br />In concrete you register an event (is something that happens) of an object instance. And that instance is going to inform you when something happens...<br /><br />Example:<br /><br /><font face="Courier New">// First we create an instance of the Button class. This is a normal<br />// button that can be clicked.<br />Button btn = new Button();<br />// Now we register the Click event. That means we get notified each<br />// time the button got clicked. The btn_Click is a method that is<br />// going to be called when the button gets clicked.<br />btn.Click &#43;= new EventHandler(btn_Click);<br /><br />// That's the method that is going to be called.<br />private void btn_Click(object sender, EventArgs e)<br />{<br />&nbsp;&nbsp;&nbsp; // Here we do something with the event.<br />&nbsp;&nbsp;&nbsp; // For example show a message box.<br />&nbsp;&nbsp;&nbsp; MessageBox.Show(&quot;Hello World!&quot;);<br />}<br /><br /></font>In the example we registered the Click event. Registering means we told the button to call the method that we provided, when somebody clicked it. The &#43;= is just notation: it means that we want to register this method (= have it called when a click happens).
 There is also -= which would mean that we don't want that method called anymore.
<br /><br /><font face="Courier New">new EventHandler</font> is a delegate. In .NET you can't directly give to the event a method. This doesn't work:<br /><br /><font face="Courier New">btn.Click &#43;= btn_Click;</font><br /><br />You need to encapsulate (wrap) it in a delegate. A delegate is something that points to a method. It holds a method and says: if you call me I'm going to call that method for you. The delegate defines also what arguments that method has: that's required because
 everything is type-safe in&nbsp;.NET.&nbsp;The general EventHandler delegate defines the method's arguments with
<font face="Courier New">object sender, EventArgs e</font><br /><br />I hope this helps <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/5a5ae15243ef4794baf39dfa00b09f38#5a5ae15243ef4794baf39dfa00b09f38</link>
		<pubDate>Sun, 26 Aug 2007 20:08:51 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/5a5ae15243ef4794baf39dfa00b09f38#5a5ae15243ef4794baf39dfa00b09f38</guid>
		<dc:creator>Christian Liensberger</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/littleguru/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>An event is a call into code that happens when something &quot;happens&quot;, like a user clicks or a key is typed or a file is downloaded.
<br /><br />Events provide a mechanism of saying &quot;when&quot; in code, such as &quot;when someone clicks this rectangle, make it blue.&quot;<br /><br />In terms of using someone else's event, I suggest playing with the C# express edition's forms. Inside a form add a button and then go to the code (right-click, view code) add the following<br /><br /><br />namespace Program<br />{<br />&nbsp;&nbsp;&nbsp; public partial class Form1 : Form<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Form1()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponent();<br /><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.button1.Click &#43;= new EventHandler(button1_Click);</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br /><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void button1_Click(object sender, EventArgs e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.BackColor = System.Drawing.Color.Blue;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(&quot;Clicked!&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font><br />&nbsp;&nbsp;&nbsp; }<br />}<br /><br />This says &quot;When button1 is clicked, change the backcolor to blue and provide a notification saying &quot;Clicked&quot;&quot;.<br /><br />Creating your own events is slightly more tricky.<br /><br />Here is some code that downloads a file asyncronously:<br /><br /><font color="#0000ff" face="Courier New" size="1">public class DownloadFile<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string downloadTo, downloadFrom;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public DownloadFile(string downloadFrom, string downloadTo)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.downloadFrom = downloadFrom;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.downloadTo = downloadTo;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new System.Threading.Thread(new System.Threading.ThreadStart(dlThread)).Start();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void dlThread()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new System.Net.WebClient().DownloadFile(downloadFrom, downloadTo);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }</font><br /><br />Now you might want to be notified when your file is downloaded, so you can add a new event, Downloaded:<br /><br /><font color="#000000" face="Courier New" size="1">public class DownloadFile<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string downloadTo, downloadFrom;<br /><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public event System.EventHandler&lt;System.EventArgs&gt; Downloaded;</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public DownloadFile(string downloadFrom, string downloadTo)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.downloadFrom = downloadFrom;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.downloadTo = downloadTo;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new System.Threading.Thread(new System.Threading.ThreadStart(dlThread)).Start();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void dlThread()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new System.Net.WebClient().DownloadFile(downloadFrom, downloadTo);<br /><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(this.Downloaded != null)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Downloaded(this, new System.EventArgs());</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br /><br /></font>The if conditional makes sure that there is something to call, incase you don't care about the Downloaded event.<br /><br />In the first example you saw that the function that is called from the event has two arguments - this is always an object sender and a second argument which
<i>derives from </i>System.EventArgs. This allows you to send additional information back from an event that occurs, such as the coordinates of a mouse-move event or the key that was typed in a keyPress event.<br /><br />In our example of DownloadFile, you might want to send back the name of the file we downloaded, in case the main program has forgotten it, so we need to add a new class:<br /><br /><font color="#000000" face="Courier New" size="1"><font color="#0000ff">public class DownloadFileEventArgs : System.EventArgs<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string name;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public string FileName { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return name;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public DownloadFileEventArgs(string name){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.name = name;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br /><br /></font></font>and in our class DownloadFile:<br /><br /><font color="#000000" face="Courier New" size="1">public class DownloadFile<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private string downloadTo, downloadFrom;<br /><font color="#0000ff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">public event System.EventHandler&lt;DownloadFileEventArgs&gt; Downloaded;</font></font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public DownloadFile(string downloadFrom, string downloadTo)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.downloadFrom = downloadFrom;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.downloadTo = downloadTo;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new System.Threading.Thread(new System.Threading.ThreadStart(dlThread)).Start();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void dlThread()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new System.Net.WebClient().DownloadFile(downloadFrom, downloadTo);<br /><font color="#0000ff"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(this.Downloaded != null)</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Downloaded(this, new </font></font><font color="#0000ff" face="Courier New" size="1">DownloadFileEventArgs</font><font color="#000000" face="Courier New" size="1"><font color="#0000ff">(downloadTo));</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; }<br /><br /></font>In our form we can now do this:<br /><br /><font color="#000000" face="Courier New" size="1">public class Form1(){<br />&nbsp;&nbsp; private DownloadFile;<br />&nbsp;&nbsp; public Form1(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InitializeComponents();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string downloadFrom = &quot;<a href="http://en.wikipedia.org/images/wiki-en.png&quot;;">http&#58;&#47;&#47;en.wikipedia.org&#47;images&#47;wiki-en.png&#34;&#59;</a><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string downloadTo = desktop &#43; @&quot;\wiki.png&quot;;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DownloadFile = new DownloadFile(from, to);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DonwloadFile.Downloaded &#43;= new System.EventHandler&lt;DownloadFileEventArgs&gt;(DownloadFile_Downloaded);<br />&nbsp;&nbsp; }<br /><br />void DownloadFile_Downloaded(object sender, </font><font color="#000000" face="Courier New" size="1">DownloadFileEventArgs
</font><font color="#000000" face="Courier New" size="1">e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(String.Format(&quot;File {0} downloaded ok!&quot;,e.FileName));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />}<br /><br /></font>I hope this clears up events in your mind a bit.<br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/d3fc7752aec94c9a91d89dfa00b09fe0#d3fc7752aec94c9a91d89dfa00b09fe0</link>
		<pubDate>Sun, 26 Aug 2007 20:10:39 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/d3fc7752aec94c9a91d89dfa00b09fe0#d3fc7752aec94c9a91d89dfa00b09fe0</guid>
		<dc:creator>evildictaitor</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/evildictaitor/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">littleguru wrote:</div>
<div class="quoteBody"><font face="Courier New">new EventHandler</font> is a delegate. In .NET you can't directly give to the event a method. This doesn't work:<br /><br /><font face="Courier New">btn.Click &#43;= btn_Click;</font><br /><br /></div>
</blockquote>
<br /><br />Um, yes you can in C# 2.0. I use it all the time <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> It makes the code much cleaner to read.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/38b1754d6af34264a7719dfa00b0a063#38b1754d6af34264a7719dfa00b0a063</link>
		<pubDate>Mon, 27 Aug 2007 11:13:21 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/38b1754d6af34264a7719dfa00b0a063#38b1754d6af34264a7719dfa00b0a063</guid>
		<dc:creator>Andrew Davey</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Andrew Davey/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>Hello Katana,<br /><br />You may want to check <a href="http://msdn.microsoft.com/vstudio/express/beginner/windows/tier2/">
video3</a> at the Beginner Developer Learning Center at MSDN. Events are very simple in essence, but the concepts aren't always simple to understand first up.<br /><br />Ultimately most useful things you will do (program)&nbsp;will be based on an Event in windows so try not to stress yourself if you can't grasp it. After programming a while you'll wonder how you ever misunderstood them.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/ba3d480076f34f118a899dfa00b0a0de#ba3d480076f34f118a899dfa00b0a0de</link>
		<pubDate>Mon, 27 Aug 2007 11:39:43 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/ba3d480076f34f118a899dfa00b0a0de#ba3d480076f34f118a899dfa00b0a0de</guid>
		<dc:creator>Vesuvius</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/vesuvius/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">Andrew Davey wrote:</div>
<div class="quoteBody">&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>littleguru wrote:</strong>
<hr size="1">
<i><font face="Courier New">new EventHandler</font> is a delegate. In .NET you can't directly give to the event a method. This doesn't work:<br /><br /><font face="Courier New">btn.Click &#43;= btn_Click;</font><br /><br /></i></td>
</tr>
</tbody>
</table>
</blockquote>
<br /><br />Um, yes you can in C# 2.0. I use it all the time <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> It makes the code much cleaner to read.</div>
</blockquote>
<br /><br />I didn't know. Nice to know. Thanks!<br /><br />But: just to make that clear. Internally the compiler is getting the arguments and creating the delegate for you.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/fe93c4590aa4464c8dc89dfa00b0a160#fe93c4590aa4464c8dc89dfa00b0a160</link>
		<pubDate>Mon, 27 Aug 2007 18:02:37 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/fe93c4590aa4464c8dc89dfa00b0a160#fe93c4590aa4464c8dc89dfa00b0a160</guid>
		<dc:creator>Christian Liensberger</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/littleguru/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>thanx alot guys for the help <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-2.gif' alt='Big Smile' />, I will check the information that you have gave me and I will see what I can do.<br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/d010e993527b46e0a1899dfa00b0a1a2#d010e993527b46e0a1899dfa00b0a1a2</link>
		<pubDate>Mon, 27 Aug 2007 19:58:13 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/d010e993527b46e0a1899dfa00b0a1a2#d010e993527b46e0a1899dfa00b0a1a2</guid>
		<dc:creator>katana_234</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/katana_234/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">littleguru wrote:</div>
<div class="quoteBody">&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>Andrew Davey wrote:</strong>
<hr size="1">
<i>&#65279;
<blockquote>
<table class="quoteTable">
<tbody>
<tr>
<td valign="top" width="10"><img src="/Themes/AlmostGlass/images/icon-quote.gif"></td>
<td class="txt3"><strong>littleguru wrote:</strong>
<hr size="1">
<i><font face="Courier New">new EventHandler</font> is a delegate. In .NET you can't directly give to the event a method. This doesn't work:<br /><br /><font face="Courier New">btn.Click &#43;= btn_Click;</font><br /><br /></i></td>
</tr>
</tbody>
</table>
</blockquote>
<br /><br />Um, yes you can in C# 2.0. I use it all the time <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> It makes the code much cleaner to read.</i></td>
</tr>
</tbody>
</table>
</blockquote>
<br /><br />I didn't know. Nice to know. Thanks!<br /><br />But: just to make that clear. Internally the compiler is getting the arguments and creating the delegate for you.</div>
</blockquote>
btw its called delegate inference or method group conversions or whatever</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/86c1b10f7bdb4e199e009dfa00b0a223#86c1b10f7bdb4e199e009dfa00b0a223</link>
		<pubDate>Tue, 28 Aug 2007 03:31:21 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/86c1b10f7bdb4e199e009dfa00b0a223#86c1b10f7bdb4e199e009dfa00b0a223</guid>
		<dc:creator>Ion Todirel</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Ion Todirel/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>Guys, Can some one give me some examples that runs on the console,&nbsp; I mean without the GUI?<br /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/07e7197ab58f4bcfae349dfa00b0a2a5#07e7197ab58f4bcfae349dfa00b0a2a5</link>
		<pubDate>Tue, 04 Sep 2007 12:23:51 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/07e7197ab58f4bcfae349dfa00b0a2a5#07e7197ab58f4bcfae349dfa00b0a2a5</guid>
		<dc:creator>katana_234</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/katana_234/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p><font color="#000000" face="Courier New" size="1">public class Program{<br />&nbsp;&nbsp; private DownloadFile;<br />&nbsp;&nbsp; public static void main(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string downloadFrom = &quot;<a href="http://en.wikipedia.org/images/wiki-en.png&quot;;">http&#58;&#47;&#47;en.wikipedia.org&#47;images&#47;wiki-en.png&#34;&#59;</a><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string downloadTo = desktop &#43; @&quot;\wiki.png&quot;;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DownloadFile = new DownloadFile(from, to);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DonwloadFile.Downloaded &#43;= new System.EventHandler&lt;DownloadFileEventArgs&gt;(DownloadFile_Downloaded);<br />&nbsp;&nbsp; }<br /><br />void DownloadFile_Downloaded(object sender, </font><font color="#000000" face="Courier New" size="1">DownloadFileEventArgs
</font><font color="#000000" face="Courier New" size="1">e)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(String.Format(&quot;File {0} downloaded ok!&quot;,e.FileName));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />}</font></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/3ae8f03263b4479ebb929dfa00b0a32c#3ae8f03263b4479ebb929dfa00b0a32c</link>
		<pubDate>Tue, 04 Sep 2007 20:26:02 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/3ae8f03263b4479ebb929dfa00b0a32c#3ae8f03263b4479ebb929dfa00b0a32c</guid>
		<dc:creator>evildictaitor</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/evildictaitor/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p>This is an example that prints just on each time the timer event fires &quot;Elapsed&quot; on the console:<br /><br /><font face="Courier New">class Program<br />{<br />&nbsp;&nbsp;&nbsp; static void Main(string[] args)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#006400"> <font color="#008000">// Set up a timer and make it run.</font><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Timers.Timer timer = new System.Timers.Timer(1000);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000"> // Tell the timer to&nbsp;call the&nbsp;&quot;timer_Elapsed&quot; method on each time the&nbsp;interval specified
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // in the constructor of the timer has been&nbsp;reached.<br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.Elapsed &#43;= new System.Timers.ElapsedEventHandler(timer_Elapsed);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000">// Start the timer.<br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; timer.Start();</font>
<p></p>
<p><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000">// Wait for the user to enter a line (for example press the ENTER key).<br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.ReadLine();<br />&nbsp;&nbsp;&nbsp; }</font></p>
<font face="Courier New">&nbsp;&nbsp;&nbsp; static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(&quot;Elapsed&quot;);<br />&nbsp;&nbsp;&nbsp; }<br />}</font><br /><br />You might just copy it into a console application project (replace the Program class there) and run it.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/89c994742a374fd4847d9dfa00b0a3b0#89c994742a374fd4847d9dfa00b0a3b0</link>
		<pubDate>Tue, 04 Sep 2007 20:38:54 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/89c994742a374fd4847d9dfa00b0a3b0#89c994742a374fd4847d9dfa00b0a3b0</guid>
		<dc:creator>Christian Liensberger</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/littleguru/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - basic C# question</title>
		<description><![CDATA[<p><p dir="ltr">Maybe it's useful to show a more complete sample containing an event definition as well.<br /><br />Let's start with the concept of a <strong>delegate</strong>, which is an object that can point to a method with a given signature:<br /><br /><font face="Courier New">delegate int BinOp(int a, int b);<br /></font><br />BinOp can point to any method that takes two ints and returns an int. For example:<br /><br /><font face="Courier New">int Add(int a, int b) { return a &#43; b; }<br /></font><br />can be pointed at by a BinOp delegate, like this:<br /><br /><font face="Courier New">BinOp add = new BinOp(Add);<br /></font><br />or even (starting from C# 2.0):<br /><br /><font face="Courier New">BinOp add = Add; //the same as the code above, just more convenient</font><br /><br />One can call the target method a delegate is pointing at by using regular method call syntax on the delegate instance, like this:<br /><br /><font face="Courier New">add(1,2); //notice the casing of <u>a</u>dd - we're not calling
<u>A</u>dd directly but through the delegate created above<br /></font><br />For the following, consider a delegate defined like this:<br /><br /><font face="Courier New">delegate void ChangedEventHandler(object o, ChangedEventArgs e);</font><br /><br /><u>Note:</u> there's a generic EventHandler class that provides a shortcut to create typical *EventHandler delegates.<br /><br /><br />Now we can cook up an <strong>event</strong> using this delegate. This allows users of a class to &quot;subscribe&quot; to an event by pointing at a method with the appropriate signature:<br /><br /><font face="Courier New">class Controller<br />{<br />&nbsp;&nbsp; public event ChangedEventHandler StateChanged; //events&nbsp;have a delegate type, in this case ChangedEventHandler<br /><br />&nbsp;&nbsp; public void DoWork()<br />&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //do work<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (StateChanged != null) //make sure someone has subscribed<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StateChanged(this, new ChangedEventArgs(...)); //delegate calling syntax<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //do more work<br />&nbsp;&nbsp; }<br />}<br /></font><br />This allows the user of the class to subscribe to the event like this:<br /><br /><font face="Courier New">Controller ctrl = new Controller();<br />ctrl.StateChanged &#43;= new ChangedEventHandler(ctrl_Changed);<br /></font><br />where ctrl_Changed is defined like this:<br /><br /><font face="Courier New">void ctrl_Changed(object o, ChangedEventArgs e)<br />{<br />&nbsp;&nbsp; //do something to handle the event; o points at the object that raised the event - you can cast it back to Controller<br />}<br /></font><br />Or, using anonymous method syntax in C# 2.0 and higher:<br /><br /><font face="Courier New">Controller ctrl = new Controller();<br />ctrl.StateChanged &#43;= delegate (object o, ChangedEventArgs e)<br />{<br />&nbsp;&nbsp; //do something to handle the event; o points at the object that raised the event - you can cast it back to Controller<br />};<br /></font><br />Hope this helps.</p></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/8edb060c405949f0a6b09dfa00b0a45a#8edb060c405949f0a6b09dfa00b0a45a</link>
		<pubDate>Tue, 04 Sep 2007 23:38:55 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/257232-basic-C-question/8edb060c405949f0a6b09dfa00b0a45a#8edb060c405949f0a6b09dfa00b0a45a</guid>
		<dc:creator>Bart De Smet</dc:creator>
		<slash:comments>12</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/bdesmet/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>