<?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>Fremus.co.za &#187; C#</title>
	<atom:link href="http://www.fremus.co.za/blog/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fremus.co.za/blog</link>
	<description>Demistifying Life and Web Development</description>
	<lastBuildDate>Sun, 27 Nov 2011 15:56:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Daily Code &#8211; Day 3 &#8211; A great reason to use interfaces</title>
		<link>http://www.fremus.co.za/blog/2011/04/daily-code-day-3-a-great-reason-to-use-interfaces/</link>
		<comments>http://www.fremus.co.za/blog/2011/04/daily-code-day-3-a-great-reason-to-use-interfaces/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 21:57:48 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/2011/04/daily-code-day-3-a-great-reason-to-use-interfaces/</guid>
		<description><![CDATA[Any class that inherits an interface is considered of that type, so it makes it easy to create implementations that do different things. More importantly it makes it easier to test. Lets say you have an Interface called IMyInterface: public interface IMyInterface { void PrintMessage(string message); } You can then create two different classes that [...]]]></description>
			<content:encoded><![CDATA[<p>Any class that inherits an interface is considered of that type, so it makes it easy to create implementations that do different things. More importantly it makes it easier to test. Lets say you have an Interface called IMyInterface:</p>
<pre class="csharp" name="code">
    public interface IMyInterface
    {
        void PrintMessage(string message);
    }
</pre>
<p>You can then create two different classes that both implement the interface:</p>
<pre name="code" class="csharp">
    public class ConcreteClassA : IMyInterface
    {
        public void PrintMessage(string message)
        {
            Console.WriteLine("My implementation here: " + message);
        }
    }
</pre>
<pre name="code" class="csharp">
    class MyConcreteClassB : IMyInterface
    {
        public void PrintMessage(string message)
        {
            Console.WriteLine("My other implementation here: " + message);
        }
    }
</pre>
<p>This means that when I implement the code like this:</p>
<pre name="code" class="csharp">

    class Program
    {
        static IMyInterface myInterface;
        static void Main(string[] args)
        {
            myInterface = new ConcreteClassA();
            myInterface.PrintMessage("hello");
            myInterface = new MyConcreteClassB();
            myInterface.PrintMessage("good day");
        }
    }
</pre>
<p>I dont create a dependency for class Program on either ConcreteClassA or MyConcreteClassB. If I make any subsequent changes to either of these classes then it doesnt affect class Program because it only deals with the interface. Its a great way to abstract your code, and its something I did not realise after reading up on it. Can an abstract class provide the same type of &#8220;abstraction&#8221;? Not really, and for a several reasons, the first being that you cannot create an instance of an abstract class and secondly you would have to expose the implementation details of the classes that inherit the abstract class. </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2011/04/daily-code-day-3-a-great-reason-to-use-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Daily Code &#8211; Day 2 &#8211; Difference between an abstract class and an interface</title>
		<link>http://www.fremus.co.za/blog/2011/04/daily-code-day-2-difference-between-an-abstract-class-and-an-interface/</link>
		<comments>http://www.fremus.co.za/blog/2011/04/daily-code-day-2-difference-between-an-abstract-class-and-an-interface/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 21:13:06 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/2011/04/daily-code-day-2-difference-between-an-abstract-class-and-an-interface/</guid>
		<description><![CDATA[I got asked this the other day and its one of those things that devs just have to know I guess, apart from the other fundamental C# stuff. I think of interfaces as thin classes or thinned out classes with no implementations of its methods, only signatures. Its the responsibility of the class that implements [...]]]></description>
			<content:encoded><![CDATA[<p>I got asked this the other day and its one of those things that devs just have to know I guess, apart from the other fundamental C# stuff. I think of interfaces as thin classes or thinned out classes with no implementations of its methods, only signatures. Its the responsibility of the class that implements that interface to provide the implementation specifics. An abstract class on the other hand cannot be instantiated but rather acts as a base class for other classes. The responsibility lies with the class that implements it to override any methods, if the methods within the abstract class are declared as abstract. Another key difference between interfaces and abstract classes is that the members within an interface are implicitly abstract, in other words the class inheriting the Interface MUST create implementations of the inherited interface, whereas an abstract class may have non abstract members. </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2011/04/daily-code-day-2-difference-between-an-abstract-class-and-an-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dealing with Circular References in EF4/JSON</title>
		<link>http://www.fremus.co.za/blog/2011/03/dealing-with-circular-references-in-ef4json/</link>
		<comments>http://www.fremus.co.za/blog/2011/03/dealing-with-circular-references-in-ef4json/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 10:22:52 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[EF4]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=760</guid>
		<description><![CDATA[I like the many-to-many mapping EF4 provides you simply because it allows such great navigation between entities and its easy to shape the query from one side to other and vice verse. The only issue is that it causes issues with JSON serialization, because the serializer does not know how to handle circular references, it [...]]]></description>
			<content:encoded><![CDATA[<p>I like the many-to-many mapping EF4 provides you simply because it allows such great navigation between entities and its easy to shape the query from one side to other and vice verse. The only issue is that it causes issues with JSON serialization, because the serializer does not know how to handle circular references, it can only serialize one way. Initially I dealt with this issue by creating &#8220;view classes&#8221; but it seemed rather tedious and pointless, so instead I started using the enumerable Select() method. It provides a very easy way to construct &#8220;anonymous objects&#8221;. So in my controller I would have a JSON Result and I would do something like this:</p>
<pre name="code" class="csharp">
Json(courses.Courses.Select(t => new { CourseTitle = t.CourseTitle, CourseCode = t.CourseCode, CourseId = t.Id }));
</pre>
<p>Pretty damn neat, considering that Courses is a EF4 entity and I dont have to go and change or adapt it to play nicely with the JSON serializer.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2011/03/dealing-with-circular-references-in-ef4json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are extension methods?</title>
		<link>http://www.fremus.co.za/blog/2011/02/what-are-extension-methods-2/</link>
		<comments>http://www.fremus.co.za/blog/2011/02/what-are-extension-methods-2/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 13:11:04 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CSharp]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=746</guid>
		<description><![CDATA[I was looking for questions that a Senior .NET developer could expect and one of the questions I would ask is to explain what extension methods are. If I am not mistaken ASP.NET MVC 2.0 uses extension methods to create HTML Helpers, which would make perfect sense since ASP.NET MVC might not have all the [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for questions that a Senior .NET developer could expect and one of the questions I would ask is to explain what extension methods are. If I am not mistaken ASP.NET MVC 2.0 uses extension methods to create HTML Helpers, which would make perfect sense since ASP.NET MVC might not have all the functionality baked in, that you may require. </p>
<p>Extension methods essentially provide a developer with a mechanism to extend the base functionality of a particular class. So lets say you want ToString() for a class to return a date in a particular format, then you could write an extension method that transforms the ToString() representation of that object into the DateTime format you desire. Creating an extension method requires that you create a static class with a static method, like:</p>
<pre name="code" class="csharp">
    static class Extensions
    {
        public static string ToString(this Concept concept, DateTime startDate)
        {
            return startDate.ToString("dddd MMMM yyyy");
        }
    }
</pre>
<p>Where concept is an arbitrary class I created. If I create an instance of Concept and call ToString() I get the overload:</p>
<pre name="code" class="csharp">
            Concept concept = new Concept();
            Console.WriteLine(concept.ToString(new DateTime()));
</pre>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2011/02/what-are-extension-methods-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>4 Reasons why I won&#8217; touch PHP</title>
		<link>http://www.fremus.co.za/blog/2010/08/4-reasons-why-i-won-touch-php/</link>
		<comments>http://www.fremus.co.za/blog/2010/08/4-reasons-why-i-won-touch-php/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 14:02:42 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=689</guid>
		<description><![CDATA[Firstly PHP is just a web scripting language and can only be used on a web server for web development, that&#8217;s it. You cannot use PHP to develop Windows apps or Linux UI or Mac OS X UI apps. If you want to implement any of the classes you will have to most probably rewrite [...]]]></description>
			<content:encoded><![CDATA[<p>Firstly PHP is just a web scripting language and can only be used on a web server for web development, that&#8217;s it. You cannot use PHP to develop Windows apps or Linux UI or Mac OS X UI apps. If you want to implement any of the classes you will have to most probably rewrite that code, which is not that great. Compare this to Python or C# and you wont have to rewrite your code, just create a class library (with C#) and re-use, re-use, re-use, re-use&#8230; Code reuse within a PHP environment is thus seemingly limited to a web environment.</p>
<p>The second reason why I will not use PHP is because there are better dynamic languages available, such as Python and Ruby.</p>
<p>The third reason I wont develop websites using PHP is because PHP devs seem to think that because the develop a site in PHP they are already building an SEO friendly website. What utter crap. There seems to be this aura around PHP that makes it look like you automatically get website awesomeness packed in. Lets not forget that the art of development on most platforms require the same disciplined processes. Whether you write unit tests for .NET or PHP &#8211; you still need to write unit tests. Whether you test websites written using PHP or ASP.NET you still have to test them in browsers &#8211; you dont get cross-browser compatibility out of the box. </p>
<p>The fourth reason I wont use PHP for development is because .NET offers programming features such as LINQ and Generics. </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2010/08/4-reasons-why-i-won-touch-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What are the data types available in C#?</title>
		<link>http://www.fremus.co.za/blog/2010/04/what-are-the-data-types-available-in-c/</link>
		<comments>http://www.fremus.co.za/blog/2010/04/what-are-the-data-types-available-in-c/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 15:42:56 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=581</guid>
		<description><![CDATA[Types in C# and the .NET framework are the fundamental building block of program design, and in C# they are divided into built-in, primitive types, and user-defined types. Generally speaking the user-defined types refer to classes, and classes are essentially made up of built-in types and other user-defined types themselves. Primitive types can also be [...]]]></description>
			<content:encoded><![CDATA[<p>Types in C# and the .NET framework are the fundamental building block of program design, and in C# they are divided into built-in, primitive types, and user-defined types. Generally speaking the user-defined types refer to classes, and classes are essentially made up of built-in types and other user-defined types themselves. Primitive types can also be seen as value types, that is a type that has a value in memory, usually called the stack. This is in contrast to reference types that are on the heap, but actually have pointers to themselves on the stack. C# offers the following built-in types:</p>
<ul>
<li>Byte</li>
<li>Char</li>
<li>Int16</li>
<li>UInt16</li>
<li>Int32</li>
<li>UInt32</li>
<li>Long</li>
<li>ULong</li>
<li>Short</li>
<li>UShort</li>
<li>Decimal</li>
<li>Double</li>
<li>Float</li>
<li>SByte</li>
<li>Single</li>
<li>Boolean</li>
<li>Int64</li>
<li>UInt64</li>
</ul>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2010/04/what-are-the-data-types-available-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Springbok Selector App</title>
		<link>http://www.fremus.co.za/blog/2010/04/springbok-selector-app/</link>
		<comments>http://www.fremus.co.za/blog/2010/04/springbok-selector-app/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 21:40:29 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Springboks]]></category>
		<category><![CDATA[HTML Agility]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=579</guid>
		<description><![CDATA[You all love the Springboks right? Those men in green who do South Africa proud? Well I guess the Kiwis or Aussies or Pommies or&#8230;err wait ok dont like the Springboks that much. But I love em and the other night I started thinking about writing an app that will allow me to select a [...]]]></description>
			<content:encoded><![CDATA[<p>You all love the Springboks right? Those men in green who do South Africa proud? Well I guess the Kiwis or Aussies or Pommies or&#8230;err wait ok dont like the Springboks that much. But I love em and the other night I started thinking about writing an app that will allow me to select a Springbok squad (or two or three) from the Super 14 teams that are currently playing. So what I did is I honestly collected some player and squad information and put it into a database, and the way I did this was to use HtmlAgility to screen scrape player information from www.sarugby.net, and I did it quite easily and successfully got some information and managed to store it. You can see on this page, albeit it might be a bit slow in coming through, that you can search for rugby players <a href="http://fremus.net/rugbyapp/" onclick="urchinTracker('/outgoing/fremus.net/rugbyapp/?referer=');">here</a> and once you have found a rugby player you can also get the rest of his team mates in his squad. Scary what you can do with a good HTML parser. I then took the information and created a few objects with properties and methods, and then I stored the information. Note that my intention is not to make money! I just liked the code that went into it. And the data that I stored I made available through an incomplete interface <a href="http://fremus.net/rugbyapp/springbokselector.aspx" onclick="urchinTracker('/outgoing/fremus.net/rugbyapp/springbokselector.aspx?referer=');">here</a>. You can click on the squads to the right, which displays the players for that squad and if you click on a player you see their information displayed. My next idea was to assign each player to one or more positions and then in the left hand pane create icons that represent rugby jerseys, and then make the players you select &#8220;addable&#8221; to the left until you reach the maximum number of players allowed.</p>
<p>I enjoyed doing it anyway, and I&#8217;m trying to do small projects at night to keep me motivated.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2010/04/springbok-selector-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doing some C#/CLR stuff</title>
		<link>http://www.fremus.co.za/blog/2010/04/doing-some-cclr-stuff/</link>
		<comments>http://www.fremus.co.za/blog/2010/04/doing-some-cclr-stuff/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 15:44:21 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=577</guid>
		<description><![CDATA[I am busy doing a CBT course with the idea of writing MCTS exams and I started by doing some stuff on C# and the .NET framework that focuses specifically on types. The .NET framework is a strongly typed framework and what we mean by strongly typed is that each variable (or type) that you [...]]]></description>
			<content:encoded><![CDATA[<p>I am busy doing a CBT course with the idea of writing MCTS exams and I started by doing some stuff on C# and the .NET framework that focuses specifically on types. The .NET framework is a strongly typed framework and what we mean by strongly typed is that each variable (or type) that you define or create in you&#8217;re code must be assigned to a type. C# in particular is a statically, manifestly and strongly typed language. The .NET framework uses the Common Type System (CTS) which means that the type int in C# and the type Integer in VB.NET refer to the same Int32 type in the CLR. It makes sense therefore that in C# you can define types of int as Int32, which means int is just an alias for Int32. Basic/intrinsic types refer to int&#8217;s, bools, long, char, unsigned int, unsigned long, byte, short, sbyte, unsigned short, float and decimal. Its important to understand this because memory in the .NET framework is divided into data structures, named the heap and stack respectively. The basic types are seen as value types that are stored on the stack in a Last In First Out basis. Enumerations, structs and constants are also seen as value types. In contrast user-defined types (objects) are stored on the heap. References to the objects are stored on the stack. If for instance you have an instance of StringBuilder called strb1 and another instance called strb2 and you instantiate strb2 be setting it to strb1 then both instances will point to the same reference on the stack. If you then set the value of strb1 it will have the same value as strb2, and vice verse.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2010/04/doing-some-cclr-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whats next?</title>
		<link>http://www.fremus.co.za/blog/2010/03/whats-next/</link>
		<comments>http://www.fremus.co.za/blog/2010/03/whats-next/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 17:06:21 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=567</guid>
		<description><![CDATA[Bill Goldberg, the wrestler, had this way of saying &#8220;You&#8217;re Next&#8221; that made whoever realise they really where next in line to get smashed. There is no next person for me though rather next objectives, but what I can say is that I have come to realise and understand several things in the last 6 [...]]]></description>
			<content:encoded><![CDATA[<p>Bill Goldberg, the wrestler, had this way of saying &#8220;You&#8217;re Next&#8221; that made whoever realise they really where next in line to get smashed. There is no next person for me though rather next objectives, but what I can say is that I have come to realise and understand several things in the last 6 months about myself and where I see myself going career-wise for the next 12 or so months. I have been to several interviews in the last while, say two years or so, and admittedly I did not succeed in all of them, but what I did take from them was that you kinda have to keep going and you have to try and get better at what you do, and more importantly get better at where you want to see yourself. I am the only one capable of making my life what I want it to be, or as Ghandi put it &#8220;Be the change you want to see&#8221;. I see myself being a great C# developer firstly. I love abstracting requirements into functional pieces of code, because it allows you to think and it allows you to do things. Becoming a great C# developer will require lots of discipline and the measure of being a great C# developer might be becoming a C# MVP, which is kind of a peer review system. Getting to that point will mean taking time to understand code and delving into the detail of what the code does. It also means compartmentalizing things into smaller understandable chunks and building to a bigger picture of things. Being a C# developer means not only focusing on  just the language itself, but also focusing on the environments that what you are developing run in. WCF for instance does not simply use C#, but it also uses other aspects of Windows and the .NET framework, which require some understanding. Another way of measuring my way to becoming that great C# developer is being able to answer most of the demands of any interview! Look at these questions, taken from <a href="http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx" onclick="urchinTracker('/outgoing/www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx?referer=');">Scott Hanselman</a>:</p>
<ul>
<li>Describe the difference between a Thread and a Process?</li>
<li>What is a Windows Service and how does its lifecycle differ from a &#8220;standard&#8221; EXE?</li>
<li>What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?</li>
<li>What is the difference between an EXE and a DLL?</li>
<li>What is strong-typing versus weak-typing? Which is preferred? Why?</li>
<li>Corillian&#8217;s product is a &#8220;Component Container.&#8221; Name at least 3 component containers that ship now with the Windows Server Family.</li>
<li>What is a PID? How is it useful when troubleshooting a system?</li>
<li>How many processes can listen on a single TCP/IP port?</li>
<li>What is the GAC? What problem does it solve?</li>
</ul>
<p>I don&#8217;t know all the answers unfortunately, and if you visit that link you will see a whole list more, which I don&#8217;t all know either. But I guess the upside is that now you can find it out and make sure you do. </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2010/03/whats-next/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interesting code with HtmlAgilityPack</title>
		<link>http://www.fremus.co.za/blog/2009/12/interesting-code-with-htmlagilitypack/</link>
		<comments>http://www.fremus.co.za/blog/2009/12/interesting-code-with-htmlagilitypack/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 12:04:09 +0000</pubDate>
		<dc:creator>fr3dr1k</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[HTML Agility]]></category>

		<guid isPermaLink="false">http://www.fremus.co.za/blog/?p=548</guid>
		<description><![CDATA[Yesterday I was busy with HTML to PDF conversion and for this I used the HTML Agility Pack. Everything worked great, except it seemed IE and FF/Chrome render different HTML. So today I took some fairly straightforward HTML and pushed it through HTMLAgility: New Website Under Construction And if I use this code to loop [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was busy with HTML to PDF conversion and for this I used the HTML Agility Pack. Everything worked great, except it seemed IE and FF/Chrome render different HTML. So today I took some fairly straightforward HTML and pushed it through HTMLAgility:</p>
<pre name="code" class="html">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

	<meta name="copyright" content="Copyright (c) 2009 Fredrik Erasmus">
	<meta name="author" content="Fredrik Erasmus">
<link rel="stylesheet" href="css/default.css" type="text/css" media="screen" />
</head>
<body>
<div id="header">
<div id="left_header"></div>
</div>
<div id="container">
<div id="main">
			New Website Under Construction
		</div>
<div id="sidebar">
		</div>
</div>
<div id="footer">
	</div>

</body>
</html>
</pre>
<p>And if I use this code to loop through the childnodes:</p>
<pre name="code" class="csharp">
            HtmlDocument doc = new HtmlDocument();
            string s;
            StringBuilder builder = new StringBuilder();
            using (StreamReader reader = new StreamReader(@"C:\Documents and Settings\user\Desktop\fremus.net\index.htm"))
            {
                while ((s = reader.ReadLine()) != null)
                {
                    builder.AppendLine(s);
                }
            }
            doc.LoadHtml(builder.ToString());
            Console.WriteLine(doc.DocumentNode.ChildNodes.Count);
            foreach (HtmlNode node in doc.DocumentNode.ChildNodes)
            {
                Console.WriteLine(node.Name);
                foreach (HtmlNode childNode in node.ChildNodes)
                {
                    Console.WriteLine("\t\t" + childNode.Name);
                    foreach (HtmlNode grandChildNode in childNode.ChildNodes)
                    {
                        Console.WriteLine("\t\t\t" + grandChildNode.Name);
                    }
                }
            }
</pre>
<p>I get the following result in my command line window:<br />
<a href="http://www.fremus.co.za/blog/wp-content/uploads/2009/12/cmdline.JPG"><img src="http://www.fremus.co.za/blog/wp-content/uploads/2009/12/cmdline.JPG" alt="cmdline" title="cmdline" width="668" height="335" class="alignleft size-full wp-image-549" /></a></p>
<p>As you can see from the output the html node has a text node. The head node has a text node, and it has 9 childnodes including 5 #text nodes. The body node has a text node as well, and it has 7 childnodes, four being #text and the other three being div. So what is this #text node? If you read <a href="http://www.w3schools.com/htmldom/dom_nodes.asp" onclick="urchinTracker('/outgoing/www.w3schools.com/htmldom/dom_nodes.asp?referer=');">this article</a> on the W3C site you will see that it states:</p>
<blockquote><p>A common error in DOM processing is to expect an element node to contain text.</p>
<p>However, the text of an element node is stored in a text node.
</p></blockquote>
<p>On the same page it then gives an example using a title tag. If you do a Google on &#8220;<em>html #text node</em>&#8220;, you will see that the second result points to <a href="http://www.quirksmode.org/dom/intro.html" onclick="urchinTracker('/outgoing/www.quirksmode.org/dom/intro.html?referer=');">an article</a> and if you read the bit on the nodes it seems that each #text node is a child. The #text nodes that appear in the body node seem to point to the text spaces after each div or each element inside the body node. If I change my code slightly:</p>
<pre name="code" class="csharp">
                    Console.WriteLine("\t\t" + childNode.Name);
                    foreach (HtmlNode grandChildNode in childNode.ChildNodes)
                    {
                        Console.WriteLine("\t\t\t" + grandChildNode.Name);
                        Console.WriteLine("\t\t\t\t" + grandChildNode.HasChildNodes);
                    }
</pre>
<p>It tells me that the divs have child elements, but the #text nodes do not. Thus it seems for each &#8216;empty space&#8217; inside a node there exists a #text node. If I amend the HTML from earlier like this:</p>
<pre name="code" class="html">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

	<meta name="copyright" content="Copyright (c) 2009 Fredrik Erasmus">
	<meta name="author" content="Fredrik Erasmus">
<link rel="stylesheet" href="css/default.css" type="text/css" media="screen" />
</head>
<body>
<div id="footer">

Test
</div>

</body>
</html>
</pre>
<p>Then the footer div will have two text nodes, and the paragraph node will have a textnode. My issues yesterday had to do with the way IE rendered the HTML and that when I used HTMLAgility to parse it, the node counts weren&#8217;t the same. From the sample HTML I have given so far that difference is negligble, but I found that if I went to a site like <a href="http://www.w3schools.com/htmldom/dom_nodes_info.asp" onclick="urchinTracker('/outgoing/www.w3schools.com/htmldom/dom_nodes_info.asp?referer=');">this one</a> and I saved the HTML from IE and Chrome into separate HTML files and I ran my code with that HTML, I got different node counts. Here are two screenshots that illustrate this:<br />
<a href="http://www.fremus.co.za/blog/wp-content/uploads/2009/12/chrome.JPG"><img src="http://www.fremus.co.za/blog/wp-content/uploads/2009/12/chrome.JPG" alt="chrome" title="chrome" width="670" height="338" class="alignleft size-full wp-image-559" /></a><a href="http://www.fremus.co.za/blog/wp-content/uploads/2009/12/ie.JPG"><img src="http://www.fremus.co.za/blog/wp-content/uploads/2009/12/ie.JPG" alt="ie" title="ie" width="666" height="337" class="alignleft size-full wp-image-560" /></a></p>
<p>The first screen is the html from the page saved from chrome and the second one is from ie. Notice the extra text nodes. </p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save" onclick="urchinTracker('/outgoing/www.addtoany.com/share_save?referer=');"><img src="http://www.fremus.co.za/blog/wp-content/plugins/add-to-any/favicon.png" width="16" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.fremus.co.za/blog/2009/12/interesting-code-with-htmlagilitypack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

