<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>digitalnetbizz's WebLog : C#</title><link>http://blogs.msdn.com/digitalnetbizz/archive/tags/C_2300_/default.aspx</link><description>Tags: C#</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>.NET Book Zero</title><link>http://blogs.msdn.com/digitalnetbizz/archive/2007/01/27/net-book-zero.aspx</link><pubDate>Sun, 28 Jan 2007 10:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1545976</guid><dc:creator>digitalnetbizz</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/digitalnetbizz/comments/1545976.aspx</comments><wfw:commentRss>http://blogs.msdn.com/digitalnetbizz/commentrss.aspx?PostID=1545976</wfw:commentRss><description>&lt;P&gt;A free book from Petzold.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;What the C or C++ Programmer Needs to Know About C# and the .NET Framework&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Available in XPS and PDF. &lt;/STRONG&gt;&lt;A href="http://www.charlespetzold.com/dotnet/index.html"&gt;&lt;STRONG&gt;http://www.charlespetzold.com/dotnet/index.html&lt;/STRONG&gt;&lt;/A&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1545976" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/digitalnetbizz/archive/tags/C_2300_/default.aspx">C#</category></item><item><title>Anonymous Methods ...</title><link>http://blogs.msdn.com/digitalnetbizz/archive/2004/02/07/anonymous-methods.aspx</link><pubDate>Sat, 07 Feb 2004 08:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:69163</guid><dc:creator>digitalnetbizz</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/digitalnetbizz/comments/69163.aspx</comments><wfw:commentRss>http://blogs.msdn.com/digitalnetbizz/commentrss.aspx?PostID=69163</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Georgia size=2&gt;I read Anonymous Methods support in Whidbey (CLR) last week and decided to play with it. This looks a lot like how Javascript (in IE) handles event - &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;lt;&lt;FONT color=#000080&gt;body&lt;/FONT&gt; &lt;FONT color=#ff0000&gt;onload&lt;/FONT&gt;="msgbox('hello')" ..&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;In general Anonymous Methods allows code block in place of delegate. For example,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face=Georgia&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#000080&gt;public&lt;/FONT&gt; &lt;FONT color=#000080&gt;class&lt;/FONT&gt; TestApp: Windows.Application&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&lt;FONT color=#000080&gt;protected override void&lt;/FONT&gt; &lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Georgia&gt;&lt;FONT face="Courier New"&gt;OnStartingUp(&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Georgia&gt;&lt;FONT face="Courier New" size=2&gt;Windows.StartingUpCancelEventArgs e)&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&lt;FONT color=#000080&gt;Window&lt;/FONT&gt; win = &lt;FONT color=#000000&gt;new&lt;/FONT&gt; &lt;FONT color=#000080&gt;Window&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;win.Text = "My Avalon Window";&lt;BR&gt;&amp;nbsp;&amp;nbsp;win.SizeChanged +=&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Georgia&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;STRONG&gt;&lt;FONT color=#000080&gt;delegate&lt;/FONT&gt; { win.Text = "My Avalon Window changed"; };&lt;/STRONG&gt;&lt;BR&gt;&amp;nbsp;...&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;My first impressions are "how can I debug this in my IDE?" and "isn't this going to make my code messy?".&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;I did a test with my VS Whidbey PDC and to my suprise, it actually work with the debugging. The following line actually being called twice when my loading my Window. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&amp;nbsp;win.SizeChanged +=&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New" size=2&gt;&lt;FONT color=#000080&gt;delegate&lt;/FONT&gt; { win.Text = "My Avalon Window changed"; };&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;The first time to setup the SizeChanged event-handling and second (and subsequent) time when my Window's size changed.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;This solves my first concern, what about the second one? I thought about it for a while, it's up to you to decide to use it or not. I think Anonymous Method is suitable for a small anonymous method (like setting 1 or 2 properties). Using Anonymous Methods will help me reduce the number of lines in code&amp;nbsp;due to less Event Handlers. For event handlers that do a bunch of things, you can always use stick to using an event handler.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=1&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=69163" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/digitalnetbizz/archive/tags/C_2300_/default.aspx">C#</category></item><item><title>Create Assembly in-memory and run it...</title><link>http://blogs.msdn.com/digitalnetbizz/archive/2004/01/31/create-assembly-in-memory-and-run-it.aspx</link><pubDate>Sat, 31 Jan 2004 21:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:65607</guid><dc:creator>digitalnetbizz</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/digitalnetbizz/comments/65607.aspx</comments><wfw:commentRss>http://blogs.msdn.com/digitalnetbizz/commentrss.aspx?PostID=65607</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Georgia size=2&gt;This has to do with CodeDom and Microsoft.CSharp namespace. The following code will let you compile and run code in memory, IMHO - perfect for scripting engine&amp;nbsp;needs:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&lt;EM&gt;using System;&lt;BR&gt;using Specialized = System.Collections.Specialized;&lt;BR&gt;using Reflection = System.Reflection;&lt;BR&gt;using CSharp = Microsoft.CSharp;&lt;BR&gt;using CodeDom = System.CodeDom.Compiler;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&lt;EM&gt;public sealed class TestCompile&lt;BR&gt;{&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&lt;EM&gt;static string ScriptCodeToCompileInMem = "public class Script {public void ScriptExecute(){System.Console.WriteLine(123);} }";&lt;BR&gt;public static void Main()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; TestCompile tc = new TestCompile();&lt;BR&gt;&amp;nbsp; tc.Execute(TestCompile.ScriptCodeToCompileInMem);&lt;BR&gt;}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&lt;EM&gt;public void Execute(string scriptCode)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; string [] source = new string[1];&lt;BR&gt;&amp;nbsp; source[0] = scriptCode;&lt;BR&gt;&amp;nbsp; CSharp.CSharpCodeProvider cscp = new CSharp.CSharpCodeProvider();&lt;BR&gt;&amp;nbsp; this.Compile(cscp, source[0]);&lt;BR&gt;}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&lt;EM&gt;private void Compile(CodeDom.CodeDomProvider provider, string source)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; CodeDom.CompilerParameters param = new CodeDom.CompilerParameters();&lt;BR&gt;&amp;nbsp; param.GenerateExecutable = false;&lt;BR&gt;&amp;nbsp; param.IncludeDebugInformation = false;&lt;BR&gt;&amp;nbsp; param.GenerateInMemory = true;&lt;BR&gt;&amp;nbsp; CodeDom.ICodeCompiler cc = provider.CreateCompiler();&lt;BR&gt;&amp;nbsp; CodeDom.CompilerResults cr = cc.CompileAssemblyFromSource(param, source);&lt;BR&gt;&amp;nbsp; Specialized.StringCollection output = cr.Output;&lt;BR&gt;&amp;nbsp; if(cr.Errors.Count !=0)&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Console.WriteLine("Error invoking scripts.");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CodeDom.CompilerErrorCollection es = cr.Errors;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach(CodeDom.CompilerError s in es)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Console.WriteLine(s.ErrorText);&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;&amp;nbsp; else&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; object o = cr.CompiledAssembly.CreateInstance("Script");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Type type = o.GetType();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type.InvokeMember ("ScriptExecute",&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" color=#000080 size=2&gt;&lt;EM&gt;Reflection.BindingFlags.InvokeMethod |&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Reflection.BindingFlags.Default, null, o, null);&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;BR&gt;}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma color=#000000 size=1&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=65607" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/digitalnetbizz/archive/tags/C_2300_/default.aspx">C#</category></item><item><title>System.Collections.Generics</title><link>http://blogs.msdn.com/digitalnetbizz/archive/2004/01/30/system-collections-generics.aspx</link><pubDate>Sat, 31 Jan 2004 07:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:65464</guid><dc:creator>digitalnetbizz</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/digitalnetbizz/comments/65464.aspx</comments><wfw:commentRss>http://blogs.msdn.com/digitalnetbizz/commentrss.aspx?PostID=65464</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Georgia size=2&gt;I&amp;nbsp;have been starting to use CLR Generics.&amp;nbsp;Absolutely useful for day to day software design and implementation.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;using Generics = System.Collections.Generics;&lt;BR&gt;...&lt;BR&gt;private Generics.IList&amp;lt;int&amp;gt; myList = new Generics.List&amp;lt;int&amp;gt;(capacity);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;myList.Add(100);&lt;BR&gt;myList.Add(201);&lt;BR&gt;myList.Add(303);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;The sample above might look very much like ArrayList and it's being use all over the place. If you compare ArrayList to Generic List, generic list is much much better because no casting to object and back (or boxing/unboxing) which will result in better performance.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Georgia size=2&gt;This is not all the benefits, you can&amp;nbsp;use other generic class like a Queue or a stack (pretty much reminds me of STL)&amp;nbsp; and of course you can write your own generic class or inherit from existing ones.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=65464" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/digitalnetbizz/archive/tags/C_2300_/default.aspx">C#</category></item></channel></rss>