<?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>Technical Articles &#8211; Sanity Free Coding</title>
	<atom:link href="http://sanity-free.org/category/tech_articles/feed" rel="self" type="application/rss+xml" />
	<link>http://sanity-free.org</link>
	<description>Methods to the Madness</description>
	<lastBuildDate>Wed, 28 Jan 2026 04:33:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>http://sanity-free.org/wp-content/uploads/2025/10/sanity-free-512-150x150.jpg</url>
	<title>Technical Articles &#8211; Sanity Free Coding</title>
	<link>http://sanity-free.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>The C# 3.0 language specification</title>
		<link>http://sanity-free.org/the_csharp_3_0_language_specification.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Fri, 28 Jul 2006 18:00:02 +0000</pubDate>
				<category><![CDATA[C# Articles]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[csharp-spec]]></category>
		<category><![CDATA[dotnet]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=175</guid>

					<description><![CDATA[I know I&#8217;m a bit late here, but better late than never. I&#8217;ve been reading over some of the changes to C# for version 3. I had heard that v3 would be v2 with the addition of the new WPF, but looking over the new spec (well, fairly new anyway), there is quite a bit [&#8230;]]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large"><img decoding="async" src="/wp-content/uploads/2025/10/csharp3.gif" alt=""/></figure>



<p>I know I&#8217;m a bit late here, but better late than never.<br><br>I&#8217;ve been reading over some of the changes to C# for version 3. I had heard that v3 would be v2 with the addition of the new WPF, but looking over the new spec (well, fairly new anyway), there is quite a bit more.<br><br>Implicit types, method extensions, lambda expressions, object / collection initializers, and LINQ&#8230; C# is going to look really weird! So much for simplicity.<br><br><strong>Implicit types</strong> (csharp meets js or PHP) allow you to define the variable without a (or with an implied) type:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>var foo = "hello";
var bar = 32;</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">foo</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;hello&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">bar</span><span style="color: #000000"> = </span><span style="color: #098658">32</span><span style="color: #000000">;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>so foo is implied to be of type string, and bar is implied to be of some numeric type.<br><br><strong>Method extensions</strong> look very strange. Think of old dog learns new tricks meets operator overloading. Method extensions allow you to create &#8220;extension&#8221; methods for existing types:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public class Bar {
    string what = "hello";
    public string What { get { return what; } set { what = value; } }
    public Bar() {}
    public void Hello() { 
        Console.WriteLine(what); 
    }
}

public static class Foo {
    public static void SayHelloToSteve(this Bar bar) {
        bar.What += " steve";
        bar.Hello();
    }
    public static void SayHelloToSomeone(this Bar bar, string who) {
        bar.What = who;
        bar.Hello();
    } 
}

public class Program {
    static void Main(string[] args) {
        Bar b = new Bar();
        b.Hello();
        b.SayHelloToSteve();
        b.SayHelloToSomeone("Hello Bob!");
    }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">class</span><span style="color: #000000"> </span><span style="color: #267F99">Bar</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">what</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;hello&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">What</span><span style="color: #000000"> { </span><span style="color: #0000FF">get</span><span style="color: #000000"> { </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">what</span><span style="color: #000000">; } </span><span style="color: #0000FF">set</span><span style="color: #000000"> { </span><span style="color: #001080">what</span><span style="color: #000000"> = </span><span style="color: #001080">value</span><span style="color: #000000">; } }</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #795E26">Bar</span><span style="color: #000000">() {}</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">Hello</span><span style="color: #000000">() { </span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">Console</span><span style="color: #000000">.</span><span style="color: #795E26">WriteLine</span><span style="color: #000000">(</span><span style="color: #001080">what</span><span style="color: #000000">); </span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">class</span><span style="color: #000000"> </span><span style="color: #267F99">Foo</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">SayHelloToSteve</span><span style="color: #000000">(</span><span style="color: #0000FF">this</span><span style="color: #000000"> </span><span style="color: #267F99">Bar</span><span style="color: #000000"> </span><span style="color: #001080">bar</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">bar</span><span style="color: #000000">.</span><span style="color: #001080">What</span><span style="color: #000000"> += </span><span style="color: #A31515">&quot; steve&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">bar</span><span style="color: #000000">.</span><span style="color: #795E26">Hello</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">SayHelloToSomeone</span><span style="color: #000000">(</span><span style="color: #0000FF">this</span><span style="color: #000000"> </span><span style="color: #267F99">Bar</span><span style="color: #000000"> </span><span style="color: #001080">bar</span><span style="color: #000000">, </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">who</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">bar</span><span style="color: #000000">.</span><span style="color: #001080">What</span><span style="color: #000000"> = </span><span style="color: #001080">who</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">bar</span><span style="color: #000000">.</span><span style="color: #795E26">Hello</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">    } </span></span>
<span class="line"><span style="color: #000000">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">class</span><span style="color: #000000"> </span><span style="color: #267F99">Program</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">Main</span><span style="color: #000000">(</span><span style="color: #0000FF">string</span><span style="color: #000000">[] </span><span style="color: #001080">args</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #267F99">Bar</span><span style="color: #000000"> </span><span style="color: #001080">b</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">Bar</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">b</span><span style="color: #000000">.</span><span style="color: #795E26">Hello</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">b</span><span style="color: #000000">.</span><span style="color: #795E26">SayHelloToSteve</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #001080">b</span><span style="color: #000000">.</span><span style="color: #795E26">SayHelloToSomeone</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;Hello Bob!&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>Notice that <code>SayHelloToSteve()</code> and <code>SayHelloToSomeone(string s)</code> are not member methods of the <code>Bar</code> class, but are invoked as if they were (by virtue of the Method extension defined in <code>Foo</code> that are available to <code>Bar</code>). This seems like a feature that will be abused to defeat inheritance (by adding reflection to the method extensions to manipulate internal class member&#8217;s without inheriting and changing functionality of the object) that would otherwise look odd and ugly.<br><br><strong>OUTPUT:</strong></p>



<pre class="wp-block-preformatted has-e-1-e-4-e-8-color has-text-color has-875-rem-font-size">hello<br>hello steve<br>Hello Bob!</pre>



<p>At this point <strong>lambda expressions</strong> don&#8217;t make much sense to me, but it seems its a way to define more than one method body in an anonymous method.<br><br><strong>Object / collection initialization</strong> makes initialization a lot easier. I don&#8217;t know if you&#8217;ve ever wanted to declare a new object inline inside a method, only to realize that you needed to set a few properties before it was used, well this is the answer to that:<br></p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>myObject.Blah(new SomeObject() { PropertyA = 1, PropertyB = "dude", PropertyC = false });</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #001080">myObject</span><span style="color: #000000">.</span><span style="color: #795E26">Blah</span><span style="color: #000000">(</span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">SomeObject</span><span style="color: #000000">() { </span><span style="color: #001080">PropertyA</span><span style="color: #000000"> = </span><span style="color: #098658">1</span><span style="color: #000000">, </span><span style="color: #001080">PropertyB</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;dude&quot;</span><span style="color: #000000">, </span><span style="color: #001080">PropertyC</span><span style="color: #000000"> = </span><span style="color: #0000FF">false</span><span style="color: #000000"> });</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>Then there&#8217;s <strong>LINQ</strong>: which feels something like SQL for C#.<br></p>



<p><a class="sf-downloads" href="http://sanity-free.org/wp-content/uploads/2025/10/CSharp3Specification.zip" data-type="link" data-id="http://sanity-free.org/wp-content/uploads/2025/10/CSharp3Specification.zip" target="_blank" rel="noreferrer noopener nofollow">feel free to download the spec here</a><br><br><em>fin</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Visual Studio .NET 2005 Troubleshooting Tool</title>
		<link>http://sanity-free.org/visual_studio_dotnet_2005_troubleshooting_tool.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Thu, 01 Dec 2005 18:00:26 +0000</pubDate>
				<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[visualstudio]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=109</guid>

					<description><![CDATA[I was having some troubles with the final release visual studio Team System. I&#8217;ve been using VS.NET 2005 on my home computer since the first previews were available on MSDN. I had installed and uninstalled each release of the IDE. I was experiencing problems viewing some of the docking window contents (entire panels loosing their [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I was having some troubles with the final release visual studio Team System. I&#8217;ve been using VS.NET 2005 on my home computer since the first previews were available on MSDN. I had installed and uninstalled each release of the IDE. I was experiencing problems viewing some of the docking window contents (entire panels loosing their contents, and were not able to be closed). I found <a href="http://dev.sanity-free.org/wp-content/uploads/2025/10/ttool.zip" target="_blank" rel="noreferrer noopener nofollow">A trouble shooting tool</a> on <a href="https://learn.microsoft.com/en-us/archive/blogs/astebner/additional-step-to-resolve-package-load-failures-in-the-final-release-of-visual-studio-2005" target="_blank" rel="noreferrer noopener">Aaron Stebner&#8217;s blog</a>. I ran it, it found an orphaned beta assembly that was causing all the problems, and now I&#8217;m up and running without any problems&#8230;<br><br>Very Nice!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Stupid .NET 1.1 Service Pack 1</title>
		<link>http://sanity-free.org/stupid_dotnet_1_1_service_pack.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Mon, 05 Sep 2005 18:00:27 +0000</pubDate>
				<category><![CDATA[C# Articles]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=105</guid>

					<description><![CDATA[Service pack 1 strikes again. This is part of a general use utility that I frequently use. An odd bug that came out of this is that the overloaded method was added in Service Pack 1 for .net v1.1 BUT NEVER DOCUMENTED!!!. Well, ok that&#8217;s not entirely true It is documented&#8230; in v2.0 documentation. So [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Service pack 1 strikes again.<br></p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>    using System;
    using System.Drawing;
    using System.IO;
    using System.Reflection;
    public class Resources {
        private Resources() {}
        public static Image LoadImageFromResource(string path) {
            Image i = null;
            using ( Stream s = 
                      Assembly.GetExecutingAssembly().GetManifestResourceStream(path) ) {
                if(s != null) i = Image.FromStream(s, true, true);
            }
            return i;
        }
    }
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Drawing</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">IO</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">using</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Reflection</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">class</span><span style="color: #000000"> </span><span style="color: #267F99">Resources</span><span style="color: #000000"> {</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #0000FF">private</span><span style="color: #000000"> </span><span style="color: #795E26">Resources</span><span style="color: #000000">() {}</span></span>
<span class="line"><span style="color: #000000">        </span><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #267F99">Image</span><span style="color: #000000"> </span><span style="color: #795E26">LoadImageFromResource</span><span style="color: #000000">(</span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">path</span><span style="color: #000000">) {</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #267F99">Image</span><span style="color: #000000"> </span><span style="color: #001080">i</span><span style="color: #000000"> = </span><span style="color: #0000FF">null</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #AF00DB">using</span><span style="color: #000000"> ( </span><span style="color: #267F99">Stream</span><span style="color: #000000"> </span><span style="color: #001080">s</span><span style="color: #000000"> = </span></span>
<span class="line"><span style="color: #000000">                      </span><span style="color: #001080">Assembly</span><span style="color: #000000">.</span><span style="color: #795E26">GetExecutingAssembly</span><span style="color: #000000">().</span><span style="color: #795E26">GetManifestResourceStream</span><span style="color: #000000">(</span><span style="color: #001080">path</span><span style="color: #000000">) ) {</span></span>
<span class="line"><span style="color: #000000">                </span><span style="color: #AF00DB">if</span><span style="color: #000000">(</span><span style="color: #001080">s</span><span style="color: #000000"> != </span><span style="color: #0000FF">null</span><span style="color: #000000">) </span><span style="color: #001080">i</span><span style="color: #000000"> = </span><span style="color: #001080">Image</span><span style="color: #000000">.</span><span style="color: #795E26">FromStream</span><span style="color: #000000">(</span><span style="color: #001080">s</span><span style="color: #000000">, </span><span style="color: #0000FF">true</span><span style="color: #000000">, </span><span style="color: #0000FF">true</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">            }</span></span>
<span class="line"><span style="color: #000000">            </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">i</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">        }</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p>This is part of a general use utility that I frequently use. An odd bug that came out of this is that the overloaded method</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers cbp-highlight-hover" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono-NL.ttf" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>Image.FromStream(Stream, Boolean, Boolean);</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #001080">Image</span><span style="color: #000000">.</span><span style="color: #795E26">FromStream</span><span style="color: #000000">(</span><span style="color: #001080">Stream</span><span style="color: #000000">, </span><span style="color: #001080">Boolean</span><span style="color: #000000">, </span><span style="color: #001080">Boolean</span><span style="color: #000000">);</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#FFFFFF;color:#0d0d0d;font-size:12px;line-height:1;position:relative">C#</span></div>



<p><br><br>was added in Service Pack 1 for .net v1.1 <strong>BUT NEVER DOCUMENTED!!!</strong>. Well, ok that&#8217;s not entirely true It is documented&#8230; in v2.0 documentation. So if you wrote this in 1.1 sp1 and deployed it to a machine without sp1 you&#8217;ll get a method not found exception when trying to load the image from stream using the above overload&#8211;non sp1 only has <code>FromStream(Stream, Boolean)</code><br><br>Nothing like being incompatible with the same version of the framework eh?</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>C# 2 Language Specification</title>
		<link>http://sanity-free.org/csharp_language_specification.html</link>
		
		<dc:creator><![CDATA[steve]]></dc:creator>
		<pubDate>Tue, 14 Jun 2005 18:00:36 +0000</pubDate>
				<category><![CDATA[C# Articles]]></category>
		<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[csharp-spec]]></category>
		<category><![CDATA[dotnet]]></category>
		<guid isPermaLink="false">http://dev.sanity-free.org/?p=103</guid>

					<description><![CDATA[I&#8217;ve been reading over the new beta 2 C# specification lately. Good Read: Download it here Cant wait until its production ready!]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;ve been reading over the new beta 2 C# specification lately.  Good Read: <a class="sf-downloads" href="http://dev.sanity-free.org/wp-content/uploads/2025/10/CSharpSpecification.doc" data-type="link" data-id="http://dev.sanity-free.org/wp-content/uploads/2025/10/CSharpSpecification.doc">Download it here</a><br><br>Cant wait until its production ready!</p>



<p></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
