<?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>Jeremy Kuhne's Blog : Managed C++</title><link>http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx</link><description>Tags: Managed C++</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using /clr and __declspec(thread)</title><link>http://blogs.msdn.com/jeremykuhne/archive/2006/04/19/578670.aspx</link><pubDate>Wed, 19 Apr 2006 03:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:578670</guid><dc:creator>jkuhne</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/578670.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=578670</wfw:commentRss><description>&lt;P&gt;Sorry I haven't been writing much lately, but a lot has been going on in Expression land.&amp;nbsp; I've switched over to working on build and setup development so you can expect to see the flavor of my posts change somewhat.&lt;/P&gt;
&lt;P&gt;Here's a frustrating bit I ran into playing around with C++/CLI:&amp;nbsp; __declspec(thread) isn't supported by the CLR.&amp;nbsp; You &lt;EM&gt;may&lt;/EM&gt; get the application to compile properly, but you'll get the following error when trying to run:&lt;/P&gt;
&lt;P&gt;"The application failed to initialize properly (0xc000007b)."&lt;/P&gt;
&lt;P&gt;You can still use thread locals, but you're stuck managing the TLS_ apis yourself.&amp;nbsp; I'm including a simple template as one suggestion on how to do this:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;template&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &amp;lt;&lt;SPAN style="COLOR: blue"&gt;typename&lt;/SPAN&gt; T&amp;gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;class&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; ThreadLocal&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;private&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;DWORD threadLocalIndex;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ThreadLocal(ThreadLocal &lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt;&amp;amp;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;T *GetPointer(&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;static_cast&lt;/SPAN&gt;&amp;lt;T*&amp;gt;(::TlsGetValue(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;threadLocalIndex));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; SetPointer(T *value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;::TlsSetValue(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;threadLocalIndex, &lt;SPAN style="COLOR: blue"&gt;static_cast&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt;*&amp;gt;(value));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; SetValue(&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; T &amp;amp;value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;T* currentPointer = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;GetPointer();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (currentPointer == NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;SetPointer(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; T(value));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;*currentPointer = value;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;T &amp;amp;GetValue(&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;T* currentPointer = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;GetPointer();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (currentPointer == NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;SetPointer(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; T());&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; *&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;GetPointer();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; DeleteValue()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;T* currentPointer = &lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;GetPointer();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (currentPointer != NULL)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;delete&lt;/SPAN&gt; currentPointer;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;SetPointer(NULL);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ThreadLocal(&lt;SPAN style="COLOR: blue"&gt;const&lt;/SPAN&gt; T&amp;amp; value)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;threadLocalIndex = ::TlsAlloc();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;SetValue(value);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ThreadLocal()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: 0.5in; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;this&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;-&amp;gt;threadLocalIndex = ::TlsAlloc();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;virtual&lt;/SPAN&gt; ~ThreadLocal()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;DeleteValue();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 2"&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;&amp;nbsp; &lt;/SPAN&gt;::TlsFree(&lt;SPAN style="COLOR: blue"&gt;this&lt;/SPAN&gt;-&amp;gt;threadLocalIndex);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 8pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;};&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above template can replace a __declspec(thread) variable fairly easily.&amp;nbsp; It will handle allocating and deallocating for you.&amp;nbsp; Simple&amp;nbsp;example:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;static __declspec(thread) int threadMeaning=42;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;... becomes ..&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;static ThreadLocal&amp;lt;int&amp;gt; threadMeaning(42);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;Using the ThreadLocal is done through SetValue() and GetValue()&amp;nbsp; ie- threadMeaning.SetValue(2001).&lt;/P&gt;
&lt;P dir=ltr&gt;The example doesn't have error checking and I haven't done anything terribly fancy. You really should try and use the framework for your thread locals if you can.&amp;nbsp; If you can't,&amp;nbsp;hopefully this will be of use.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=578670" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item><item><title>Looking at double buffering and the new BufferedGraphics classes</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/09/08/462344.aspx</link><pubDate>Thu, 08 Sep 2005 09:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:462344</guid><dc:creator>jkuhne</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/462344.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=462344</wfw:commentRss><description>&lt;P&gt;I started spending some time looking at double buffering with Windows Forms a little while back and noticed that in the 2.0 framework there are a couple of new BufferedGraphics classes.&amp;nbsp; I toyed around with them a bit and got them to work, but didn’t &lt;EM&gt;really&lt;/EM&gt; understand what was going on.&amp;nbsp; Looking into things again the past few days I found the available material somewhat lacking, so I did some investigation using &lt;A href="http://www.aisto.com/roeder/dotnet/"&gt;Reflector&lt;/A&gt; and thought I’d share what I’ve found.&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;[What is double buffering?&amp;nbsp; It’s drawing on an off-screen bitmap then copying it onto the display to help avoid redraw flickering issues.]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Double buffering will be handled automatically for you if the &lt;STRONG&gt;OptimizedDoubleBuffer&lt;/STRONG&gt; style is set to true through &lt;FONT face="Courier New"&gt;SetStyle()&lt;/FONT&gt;.&amp;nbsp;&amp;nbsp; MSDN: &lt;A href="http://msdn2.microsoft.com/library/b367a457(en-us,vs.80).aspx"&gt;Double Buffered Graphics&lt;/A&gt;.&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;[Double buffering&amp;nbsp;will also be done if the &lt;STRONG&gt;DoubleBuffer&lt;/STRONG&gt;, &lt;STRONG&gt;UserPaint&lt;/STRONG&gt;, and &lt;STRONG&gt;AllPaintingInWmPaint&lt;/STRONG&gt; styles are &lt;EM&gt;all&lt;/EM&gt; set to true.&amp;nbsp; Setting the DoubleBuffered property to true is another way to set the OptimizedDoubleBuffer style to true (as well as AllPaintingInWmPaint, but oddly it doesn’t turn off AllPaintingInWmPaint when set to false).&amp;nbsp; As of Beta2 the documentation says that DoubleBuffer style is obsolete, but it is still checked in the code.&amp;nbsp; (I’ve seen mention that double buffering is on by default in the 2.0 framework, but I haven’t seen this to be true in Beta2.)]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you wish to manually manage double buffering you can do so using the new BufferedGraphics classes.&amp;nbsp;&amp;nbsp; MSDN: &lt;A href="http://msdn2.microsoft.com/library/tdk2485d(en-us,vs.80).aspx"&gt;How to: Manually Manage Buffered Graphics&lt;/A&gt;.&amp;nbsp; There are three key classes that you need to be familiar with:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/hwac9f5b(en-us,vs.80).aspx"&gt;BufferedGraphics&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/tt8yksdk(en-us,vs.80).aspx"&gt;BufferedGraphicsContext&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/k176f1xt(en-us,vs.80).aspx"&gt;BufferedGraphicsManager&lt;/A&gt;.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;These classes are what Windows Forms uses to double buffer if the appropriate styles are set.&amp;nbsp; Let’s take a in-depth look at each in turn:&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;U&gt;BufferedGraphicsManager&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;System.Drawing.BufferedGraphicsManager&lt;/FONT&gt; is a pretty simple class that has a static constructor that creates a &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; instance that you can obtain through the &lt;FONT face="Courier New"&gt;Current&lt;/FONT&gt; property.&amp;nbsp; It also registers itself with the &lt;FONT face="Courier New"&gt;ProcessExit&lt;/FONT&gt; and &lt;FONT face="Courier New"&gt;DomainUnload&lt;/FONT&gt; events so that it can call &lt;FONT face="Courier New"&gt;Invalidate()&lt;/FONT&gt; on the created &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; as the app shuts down.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial&gt;BufferedGraphicsContext&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; class handles allocating and releasing the off-screen bitmap that you draw to (which you access through the &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; class it gives back to you).&amp;nbsp; You can get an app-wide instance of this class from the &lt;FONT face="Courier New"&gt;BufferedGraphicsManager.Current&lt;/FONT&gt; property.&amp;nbsp; You can also manually create a &lt;FONT face="Courier New" color=#000000&gt;BufferedGraphicsContext&lt;/FONT&gt; class, but then you are responsible for calling &lt;FONT face="Courier New"&gt;Dispose()&lt;/FONT&gt; when you are finished with it to release created resources.&amp;nbsp; Note that disposing of a context class will delete its &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object if it has one active. (An alternative to calling &lt;FONT face="Courier New"&gt;Dispose&lt;/FONT&gt; is calling &lt;FONT face="Courier New"&gt;Invalidate(),&lt;/FONT&gt; which will call &lt;FONT face="Courier New"&gt;Dispose()&lt;/FONT&gt; when you dispose of the &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object created through the context.)&lt;BR&gt;&amp;nbsp;&lt;BR&gt;Calling &lt;FONT face="Courier New"&gt;Allocate()&lt;/FONT&gt; from a &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; will create a compatible &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; object / Display Device Context (DC) that wraps an off-screen bitmap for the specified &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; object / DC.&amp;nbsp; This new &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; object is accessed through the &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; property of the &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object.&amp;nbsp; [Win32 Fyi:&amp;nbsp; The bitmap is created using &lt;FONT face="Courier New"&gt;CreateDIBSection&lt;/FONT&gt;.&amp;nbsp; &lt;FONT face="Courier New"&gt;hSection&lt;/FONT&gt; is set to &lt;FONT face="Courier New"&gt;NULL&lt;/FONT&gt; which allows the system to allocate the memory for the bitmap, which is then deallocated when the class later calls&amp;nbsp;&lt;FONT face="Courier New"&gt;DeleteObject&lt;/FONT&gt; on the bitmap handle.]&lt;/P&gt;
&lt;P&gt;Setting the &lt;FONT face="Courier New"&gt;MaximumBuffer&lt;/FONT&gt; property sets the threshold for&amp;nbsp;the bitmap size that is kept in memory after disposing of a &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object.&amp;nbsp; If the size requested is larger than the &lt;FONT face="Courier New"&gt;MaximumBuffer&lt;/FONT&gt; size a &lt;EM&gt;new&lt;/EM&gt; temporary &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; is created that will automatically be disposed of when the &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object it returns is disposed.&amp;nbsp; (Note that if the context has already created a &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object that has &lt;EM&gt;not&lt;/EM&gt; been disposed a temporary &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; will also be created.)&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;U&gt;BufferedGraphics&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This is the object that provides you access to the off-screen bitmap that a &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; class creates (through &lt;FONT face="Courier New"&gt;Allocate()&lt;/FONT&gt;).&amp;nbsp; You can draw to the &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; object returned from the &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; property just like you normally would.&amp;nbsp; When you’re finished drawing, calling &lt;FONT face="Courier New"&gt;Render()&lt;/FONT&gt; on the &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object will call the Win32 &lt;FONT face="Courier New"&gt;BitBlt&lt;/FONT&gt; function using the &lt;FONT face="Courier New"&gt;SRCCOPY&lt;/FONT&gt; ROP method (just copies), positioning the bitmap based off of the &lt;FONT face="Courier New"&gt;Position&lt;/FONT&gt; property of the&amp;nbsp;rectangle passed to the &lt;FONT face="Courier New"&gt;Allocate()&lt;/FONT&gt; method when creating this &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; object.&amp;nbsp;&amp;nbsp; By default this copies to the &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; object / DC specified in the &lt;FONT face="Courier New"&gt;Allocate()&lt;/FONT&gt; method, but you can specify any &lt;FONT face="Courier New"&gt;Graphics&lt;/FONT&gt; object / DC as a destination through the &lt;FONT face="Courier New"&gt;Render()&lt;/FONT&gt; overloads.&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial&gt;The Windows Forms WM_PAINT&amp;nbsp; Handler&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I’ve included some (very) pseudo-code here to help give you an idea of what happens when a Windows Forms control handles the &lt;FONT face="Courier New"&gt;WM_PAINT&lt;/FONT&gt; message from Windows.&amp;nbsp; This is important to look at to understand how the different styles will affect the painting process.&amp;nbsp; (Note that there are also calls to &lt;FONT face="Courier New"&gt;BeginPaint/EndPaint&lt;/FONT&gt; and &lt;FONT face="Courier New"&gt;SelectPalette&lt;/FONT&gt;.&amp;nbsp; The &lt;FONT face="Courier New"&gt;HDC&lt;/FONT&gt; is also set up.)&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;if (OptimizedDoubleBuffer || (DoubleBuffer &amp;amp;&amp;amp; UserPaint &amp;amp;&amp;amp; AllPaintingInWmPaint))&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;create a BufferedGraphics from the context returned from the BufferedGraphicsManager&lt;BR&gt;&amp;nbsp;set the clipping rectangle&lt;BR&gt;&amp;nbsp;save the Graphics state&lt;BR&gt;&amp;nbsp;call &lt;STRONG&gt;OnPaintBackground&lt;/STRONG&gt;&amp;nbsp; (which calls &lt;STRONG&gt;PaintBackground&lt;/STRONG&gt;())&amp;nbsp; if not &lt;STRONG&gt;Opaque&lt;/STRONG&gt; style&lt;BR&gt;&amp;nbsp;restore the Graphics state&lt;BR&gt;&amp;nbsp;call &lt;STRONG&gt;OnPaint&lt;/STRONG&gt; which then raises the &lt;STRONG&gt;Paint&lt;/STRONG&gt; event&lt;BR&gt;&amp;nbsp;render the BufferedGraphics object&lt;BR&gt;}&lt;BR&gt;else&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;if (AllPaintingInWmPaint) call OnPaintBackground delegates if not Opaque style // unless an HDC is passed in WPARAM, not sure when this will happen&lt;BR&gt;&amp;nbsp;call OnPaint which then raises the Paint event&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Two crucial things:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Don't turn on double buffering if you're handling it yourself. If you have double buffering turned on and you're attempting handle your own double buffering of it you'll end up copying your back buffer into another back buffer that is then copied to the screen.&lt;/LI&gt;
&lt;LI&gt;The other interesting note here is that &lt;FONT face="Courier New"&gt;WM_ERASEBACKBROUND&lt;/FONT&gt; message handler checks for the the &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;AllPaintingInWmPaint&lt;/FONT&gt;&lt;/STRONG&gt; style.&amp;nbsp; You still get the background painted for you in the &lt;FONT face="Courier New"&gt;WM_PAINT&lt;/FONT&gt; handler if you don't have the &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;Opaque&lt;/FONT&gt;&lt;/STRONG&gt; style set.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;BR&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;&lt;U&gt;Key Takeaways:&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Don’t bother with the &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; classes if you want simple double buffering.&amp;nbsp; Set the &lt;FONT face="Courier New"&gt;DoubleBuffered&lt;/FONT&gt; property to true.&lt;/LI&gt;
&lt;LI&gt;If you want to handle your own double buffering:&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Set the &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;DoubleBuffered&lt;/STRONG&gt;&lt;/FONT&gt; property and the &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;DoubleBuffer&lt;/STRONG&gt;&lt;/FONT&gt; style to &lt;STRONG&gt;&lt;FONT face="Courier New" color=#000000&gt;false&lt;/FONT&gt;&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;Override &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;OnPaint()&lt;/STRONG&gt;&lt;/FONT&gt;. Don’t call the base unless you deliberately want the &lt;FONT face="Courier New"&gt;Paint&lt;/FONT&gt; event raised.&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;If you are handling the background yourself set the &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;AllPaintingInWmPaint&lt;/STRONG&gt;&lt;/FONT&gt; and the &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;Opaque&lt;/STRONG&gt;&lt;/FONT&gt; styles.&lt;/LI&gt;
&lt;LI&gt;If you want to minimize allocations of bitmaps:&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Ensure you have created your &lt;EM&gt;own&lt;/EM&gt; separate &lt;FONT face="Courier New" color=#000000&gt;&lt;STRONG&gt;BufferedGraphicsContext&lt;/STRONG&gt;&lt;/FONT&gt; classes for each &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;BufferedGraphics&lt;/STRONG&gt;&lt;/FONT&gt; you intend to use.&lt;/LI&gt;
&lt;LI&gt;Ensure your &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;MaximumBuffer&lt;/STRONG&gt;&lt;/FONT&gt; property is large enough to hold the size of the off-screen bitmap.&lt;/LI&gt;
&lt;LI&gt;Always call &lt;STRONG&gt;&lt;FONT face="Courier New"&gt;Dispose()&lt;/FONT&gt;&lt;/STRONG&gt; on a &lt;FONT face="Courier New"&gt;BufferedGraphics&lt;/FONT&gt; class when you're done drawing.&amp;nbsp; (Specifically, before you call &lt;FONT face="Courier New" color=#000000&gt;Allocate&lt;/FONT&gt; again on it's hosting &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt;.)&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Call &lt;FONT face="Courier New"&gt;&lt;STRONG&gt;Dispose()&lt;/STRONG&gt;&lt;/FONT&gt; on any &lt;FONT face="Courier New"&gt;BufferedGraphicsContext&lt;/FONT&gt; class you create yourself when you're finished with them.&lt;/LI&gt;
&lt;LI&gt;Remember the limitations:&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;You can’t change where the back buffer is copied to after allocating. (The offset in the target DC, that is.)&lt;/LI&gt;
&lt;LI&gt;You can’t specify the raster operation (ROP).&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's about it for now.&amp;nbsp; This ended up being much more detailed than I expected and I've gotten a bit drowsy so hopefully this came through somewhat clear.&amp;nbsp; Any comments/corrections are welcome.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=462344" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/C_2300_/default.aspx">C#</category></item><item><title>Setting up C++ Interop (with Win32) in VS 2005.</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/09/08/462259.aspx</link><pubDate>Thu, 08 Sep 2005 03:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:462259</guid><dc:creator>jkuhne</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/462259.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=462259</wfw:commentRss><description>&lt;P&gt;I've already given the steps necessary to make this happen in an earlier &lt;a href="http://blogs.msdn.com/jeremykuhne/archive/2005/06/11/428363.aspx"&gt;post&lt;/A&gt;, but as this will come up so much I decided to pull it into a seperate post with more explicit details.&amp;nbsp; The basic things you need again are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/k8d11d4s(en-us,vs.80).aspx"&gt;/clr &lt;/A&gt;option set for the project.&amp;nbsp; (Common Language Runtime support property under General.) 
&lt;LI&gt;Include the appropriate Win32 headers.&amp;nbsp; &lt;FONT size=2&gt;(&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &amp;lt;windows.h&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt; is the main one) 
&lt;LI&gt;Appropriate target OS #defines. (see &lt;A href="http://msdn.microsoft.com/library/en-us/winprog/winprog/using_the_windows_headers.asp"&gt;&lt;FONT color=#003399&gt;Using the Windows Headers&lt;/FONT&gt;&lt;/A&gt; for the right values) 
&lt;LI&gt;If the project was started from one of the CLR templates, you'll need to remove $(NoInherit) from the Additional Dependencies property under Linker:Input.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;As mentioned in the earlier post, it's probably a good idea to put the Win32 #includes in a precompiled header for speedier compilation&amp;nbsp;(stdafx.h typically, see &lt;A href="http://msdn.microsoft.com/library/en-us/vccore/html/_core_creating_precompiled_header_files.asp"&gt;&lt;FONT color=#003399&gt;Creating Precompiled Header Files&lt;/FONT&gt;&lt;/A&gt; for more info).&amp;nbsp; Here is what this looks like (for the latest versions):&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;&lt;FONT color=#006400&gt;//
// Target platform defines:
//&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#ifndef&lt;/FONT&gt; WINVER
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; WINVER 0x0501
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#ifndef&lt;/FONT&gt; _WIN32_WINNT
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _WIN32_WINNT 0x0501
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#ifndef&lt;/FONT&gt; _WIN32_WINDOWS
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _WIN32_WINDOWS 0x0410
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#ifndef&lt;/FONT&gt; _WIN32_IE
&lt;FONT color=#0000ff&gt;#define&lt;/FONT&gt; _WIN32_IE 0x0500
&lt;FONT color=#0000ff&gt;#endif&lt;/FONT&gt;

&lt;FONT color=#006400&gt;// Disable warning for XML comments.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;#pragma&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;warning&lt;/FONT&gt;( &lt;FONT color=#0000ff&gt;disable&lt;/FONT&gt; : 4634 )

&lt;FONT color=#006400&gt;// Windows Header Files:
&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &lt;FONT color=#a52a2a&gt;&amp;lt;windows.h&amp;gt;&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;#pragma warning&lt;/FONT&gt;( &lt;FONT color=#0000ff&gt;default&lt;/FONT&gt; : 4634 )&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Ok, but what about the warning disable?&amp;nbsp; In Beta 2, turning on XML comments would cause parsing of all included headers as well.&amp;nbsp; Not really what you want given there are a number of places XML delimiters inadvertently show up&amp;nbsp;(they aren't actual XML comments, so you are likely to get errors).&amp;nbsp; My last word was that in the final code includes that have the &lt;FONT face="Courier New" size=2&gt;&lt;STRONG&gt;#include &amp;lt;header.h&amp;gt;&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; (as opposed to the &lt;FONT face="Courier New" size=2&gt;&lt;STRONG&gt;#include "header.h"&lt;/STRONG&gt;)&lt;/FONT&gt; format will not be parsed to make this easier.&lt;/P&gt;
&lt;P&gt;So... step-by-step:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create or load a project.&lt;/LI&gt;
&lt;LI&gt;Set the /clr switch.&lt;/LI&gt;
&lt;LI&gt;Ensure the dependencies property isn't set to $(NoInherit).&lt;/LI&gt;
&lt;LI&gt;Add the relevant Win32 #defines and #includes if needed (see above).&lt;/LI&gt;
&lt;LI&gt;Code. (See my other articles [&lt;a href="http://blogs.msdn.com/jeremykuhne/archive/2005/06/11/428363.aspx"&gt;1&lt;/A&gt;], [&lt;a href="http://blogs.msdn.com/jeremykuhne/archive/2005/06/12/428417.aspx"&gt;2&lt;/A&gt;] for more details.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;That's basically it.&amp;nbsp; Some other useful links from MSDN:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/ms173265(en-us,vs.80).aspx"&gt;How To: Migrate to /clr&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/ms173266(en-us,vs.80).aspx"&gt;Initialization of Mixed Assemblies &lt;/A&gt;(if you have a DLL with a DllMain, look at this)&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=462259" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item><item><title>Generic Collections IV</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/07/24/generic-collections-iv.aspx</link><pubDate>Mon, 25 Jul 2005 00:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:442801</guid><dc:creator>jkuhne</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/442801.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=442801</wfw:commentRss><description>&lt;P&gt;Back again, and as promised...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial size=4&gt;Subclassing Generic Collections&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The framework provides three basic&amp;nbsp;collections that are intended for derivation.&amp;nbsp; They are located in&amp;nbsp;&lt;CODE&gt;System.Collections.ObjectModel:&lt;/CODE&gt;&lt;/P&gt;&lt;CODE&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/ms132397(en-us,vs.80).aspx"&gt;Collection&amp;lt;T&amp;gt;&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/ms132438(en-us,vs.80).aspx"&gt;KeyedCollection&amp;lt;TKey, TItem&amp;gt;&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/ms132474(en-us,vs.80).aspx"&gt;ReadOnlyCollection&amp;lt;T&amp;gt;&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/CODE&gt;
&lt;P&gt;They are all intended to provide base implementations of the following interfaces:&lt;/P&gt;&lt;CODE&gt;
&lt;UL&gt;
&lt;LI&gt;IList, IList&amp;lt;T&amp;gt;&lt;/LI&gt;
&lt;LI&gt;ICollection, ICollection&amp;lt;T&amp;gt;&lt;/LI&gt;
&lt;LI&gt;IEnumerable, IEnumerable&amp;lt;T&amp;gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/CODE&gt;
&lt;P&gt;&lt;CODE&gt;Collection&amp;lt;T&amp;gt;&lt;/CODE&gt;&amp;nbsp;stores it's data internally as &lt;CODE&gt;IList&amp;lt;T&amp;gt;&lt;/CODE&gt; (and also takes &lt;CODE&gt;IList&amp;lt;T&amp;gt;&lt;/CODE&gt; in one of the constructors).&amp;nbsp; The methods that actually modify the internal &lt;CODE&gt;IList&amp;lt;T&amp;gt;&lt;/CODE&gt; are virtual (and protected):&lt;/P&gt;&lt;CODE&gt;
&lt;UL&gt;
&lt;LI&gt;ClearItems()&lt;/LI&gt;
&lt;LI&gt;InsertItem()&lt;/LI&gt;
&lt;LI&gt;RemoveItem()&lt;/LI&gt;
&lt;LI&gt;SetItem()&lt;/LI&gt;&lt;/UL&gt;&lt;/CODE&gt;
&lt;P&gt;This class is intended for when you wish to handle all modifications done&amp;nbsp;to the collection.&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;KeyedCollection&amp;lt;TKey, TItem&amp;gt;&lt;/CODE&gt; is an abstract class that derives from &lt;CODE&gt;Collection&amp;lt;T&amp;gt;&lt;/CODE&gt;.&amp;nbsp; It is meant to store values where the key is imbedded within the value.&amp;nbsp; It overrides the virtual methods from &lt;CODE&gt;Collection&amp;lt;T&amp;gt;&lt;/CODE&gt; and adds an abstract &lt;CODE&gt;GetKeyForItem().&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;ReadOnlyCollection&amp;lt;T&amp;gt;&lt;/CODE&gt;&amp;nbsp;supports the same interfaces as&amp;nbsp;&lt;CODE&gt;Collection&amp;lt;T&amp;gt;&lt;/CODE&gt; and also stores it's data as an &lt;CODE&gt;IList&amp;lt;T&amp;gt;.&amp;nbsp;&lt;/CODE&gt; There are no virtual methods and all of the iterface method&amp;nbsp;implementations that would normally modify the stored &lt;CODE&gt;IList&amp;lt;T&amp;gt;&lt;/CODE&gt; are private and throw if called.&amp;nbsp; (&lt;CODE&gt;Add()&lt;/CODE&gt;, &lt;CODE&gt;Clear()&lt;/CODE&gt;, &lt;CODE&gt;Remove()&lt;/CODE&gt;, etc.)&amp;nbsp; The only time the collection is modified is when it is constructed.&amp;nbsp; (i.e., you pass in an existing&amp;nbsp;&lt;CODE&gt;IList&amp;lt;T&amp;gt;&lt;/CODE&gt;)&lt;/P&gt;
&lt;P&gt;Now all of the other collections are not sealed, so you can derive from any of them.&amp;nbsp; They do not, however, have any methods marked as virtual (other than &lt;CODE&gt;GetObjectData()&lt;/CODE&gt; and &lt;CODE&gt;OnSerialization()&lt;/CODE&gt;).&amp;nbsp;&amp;nbsp;Why would you want to override them if you cannot change/intercept their behavior?&amp;nbsp; There are two reasons I've come up with so far:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Attaching utility methods.&lt;/LI&gt;
&lt;LI&gt;Readability.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Lets say you had a path with a number of points.&amp;nbsp; You could create a &lt;CODE&gt;List&amp;lt;Point&amp;gt;&lt;/CODE&gt; to represent said path.&amp;nbsp; This works, but say you want to create a list of your paths?&amp;nbsp; This turns into &lt;CODE&gt;List&amp;lt;List&amp;lt;Point&amp;gt;&amp;gt;.&amp;nbsp;&lt;/CODE&gt; Hmm.&amp;nbsp; Not nice.&amp;nbsp; In some cases you might even end up with &lt;CODE&gt;List&amp;lt;List&amp;lt;List&amp;lt;Point&amp;gt;&amp;gt;&amp;gt;&lt;/CODE&gt;.&amp;nbsp;&amp;nbsp; Ugh.&amp;nbsp; Since &lt;CODE&gt;List&amp;lt;Point&amp;gt;&lt;/CODE&gt; represents a specific object we could subclass &lt;CODE&gt;List&amp;lt;T&amp;gt;&lt;/CODE&gt; as follows:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public class&lt;/FONT&gt; Path : &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;Point&amp;gt;
{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Need a constructor (and you'd likely want one that takes IEnumerable&amp;lt;T&amp;gt;):
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;&lt;INT&gt; Path() : &lt;FONT color=#0000ff&gt;base&lt;/FONT&gt;() {};
}&lt;/PRE&gt;
&lt;P&gt;Now we can say &lt;CODE&gt;List&amp;lt;Path&amp;gt;&lt;/CODE&gt;.&amp;nbsp; Much clearer- the sort of code you'd want to read/maintain.&amp;nbsp; In addition we can add useful utility methods to our new &lt;CODE&gt;Path&lt;/CODE&gt; class such as &lt;CODE&gt;IsClosed()&lt;/CODE&gt; or &lt;CODE&gt;IsValid()&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;That's about it for subclassing for now.&amp;nbsp; Lets take a look at something I hinted at earlier...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial size=4&gt;System.Array&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Ends up that most of the useful methods in List&amp;lt;T&amp;gt; have static equivalents in System.Array.&amp;nbsp; Very useful.&amp;nbsp; Looking at a previous example we could have had:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; SumUpMeaningDemo()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;[] magicNumbers = { 7, 13, 1000, 42, 9 };
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; total = 0;

&lt;FONT color=#008000&gt;&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008080&gt;Array&lt;/FONT&gt;.ForEach&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;/FONT&gt;&lt;FONT color=#000000&gt;newNumbers, &lt;FONT color=#0000ff&gt;delegate&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; number) { total += number; });
&lt;/FONT&gt;&lt;/FONT&gt;}&lt;/PRE&gt;
&lt;P&gt;Since these are static methods you need to specifiy the type of the array and which array you're working on.&amp;nbsp; Other than that things work pretty much the same.&amp;nbsp; Happy days that the framework team added this support.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial size=4&gt;Wait a Minute...&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Those that read ahead may have noticed that &lt;EM&gt;only&lt;/EM&gt; &lt;CODE&gt;List&amp;lt;T&amp;gt;&lt;/CODE&gt; and &lt;CODE&gt;Array&lt;/CODE&gt; have methods that utilize the system delegate types.&amp;nbsp; It's true.&amp;nbsp; Before you get too depressed about this, in a future post I'll discuss a project that gives you loads of functionality for all of the generic interface types (&lt;CODE&gt;IList&amp;lt;T&amp;gt;&lt;/CODE&gt;, &lt;CODE&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/CODE&gt;, &lt;CODE&gt;ICollection&amp;lt;T&amp;gt;&lt;/CODE&gt;).&amp;nbsp; It is an amazingly useful package called &lt;A href="http://www.wintellect.com/powercollections/"&gt;PowerCollections&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Till then...&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=442801" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Generic Collections III</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/07/24/generic-collections-iii.aspx</link><pubDate>Sun, 24 Jul 2005 05:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:442602</guid><dc:creator>jkuhne</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/442602.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=442602</wfw:commentRss><description>&lt;P&gt;So far I've gone over the basics of&amp;nbsp;generic collections and moved on to looking at&amp;nbsp;List&amp;lt;T&amp;gt; and Predicate&amp;lt;T&amp;gt;.&amp;nbsp; As mentioned yesterday, this post will deal with subclassing and the other System delegate types.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial size=4&gt;The "Other" System.Delegates&amp;nbsp;&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;We've already looked at &lt;CODE&gt;System.Predicate&amp;lt;T&amp;gt;.&amp;nbsp;&lt;/CODE&gt; Now we can turn our attention to the rest of the &lt;CODE&gt;System&lt;/CODE&gt; deleagte types:&lt;/P&gt;&lt;CODE&gt;
&lt;UL&gt;
&lt;LI&gt;Action&amp;lt;T&amp;gt;&lt;/LI&gt;
&lt;LI&gt;Comparison&amp;lt;T&amp;gt;&lt;/LI&gt;
&lt;LI&gt;Converter&amp;lt;TInput, TOutput&amp;gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/CODE&gt;
&lt;P&gt;As a reminder, here's the signature of &lt;CODE&gt;Predicate&amp;lt;T&amp;gt;&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public delegate bool&lt;/FONT&gt; Predicate&amp;lt;T&amp;gt;(T obj);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Now here's &lt;CODE&gt;Action&amp;lt;T&amp;gt;&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public delegate void&lt;/FONT&gt; Action&amp;lt;T&amp;gt;(T obj);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;The only difference from &lt;CODE&gt;Predicate&amp;lt;T&amp;gt;&lt;/CODE&gt; is that &lt;CODE&gt;Action&amp;lt;T&amp;gt;&lt;/CODE&gt; returns a &lt;CODE&gt;void&lt;/CODE&gt; (nothing).&amp;nbsp; One way to think of this is "just do this".&amp;nbsp; The only place it's used (currently) is with &lt;CODE&gt;List&amp;lt;T&amp;gt;.ForEach().&amp;nbsp;&lt;/CODE&gt; (Well, one other place, but that comes later.)&amp;nbsp; For each?&amp;nbsp; Yes, it's pretty much the same.&amp;nbsp; Let's say you have a &lt;CODE&gt;List&amp;lt;int&amp;gt;&lt;/CODE&gt; that you want to sum up:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; SumUpMeaningDemo()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; magicNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[] { 7, 13, 1000, 42, 9 });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; total = 0;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The traditional way:
&amp;nbsp;&amp;nbsp;&amp;nbsp;// foreach (int number in magicNumbers)
&amp;nbsp;&amp;nbsp;&amp;nbsp;// {
&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total += number;
&amp;nbsp;&amp;nbsp;&amp;nbsp;// }&lt;/FONT&gt;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// A new way:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;magicNumbers.ForEach(&lt;FONT color=#0000ff&gt;delegate&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; number){ total += number; });
}&lt;/PRE&gt;
&lt;P&gt;The syntax is a little different, but not much visible difference.&amp;nbsp; So what to use then?&amp;nbsp; What's the not-so-visible difference, if any?&amp;nbsp; Well this surprised me, but the &lt;CODE&gt;List&amp;lt;T&amp;gt;.ForEach()&lt;/CODE&gt; is &lt;EM&gt;twice&lt;/EM&gt; as fast (in this example, done a million times) as using &lt;CODE&gt;foreach&lt;/CODE&gt; on the &lt;CODE&gt;List&amp;lt;T&amp;gt;.&amp;nbsp;&lt;/CODE&gt; Why is that?&amp;nbsp; I'm not terribly great at IL (Intermediate Language)&amp;nbsp;so I can't give you the final word on this, but when you do a &lt;CODE&gt;foreach&lt;/CODE&gt; in code you actually end up with the equivalent of:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#008000&gt;// For reference, this is the code in Enumerator&amp;lt;int&amp;gt;.MoveNext():&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;public bool&lt;/FONT&gt;&lt;FONT color=#000000&gt; MoveNext(&lt;/FONT&gt;&lt;FONT color=#000000&gt;)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;FONT color=#000000&gt; (this.version != &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;FONT color=#000000&gt;.list._version)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;/FONT&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// throw;&lt;/FONT&gt;
&lt;FONT color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;&lt;FONT color=#000000&gt; (&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;FONT color=#000000&gt;.index &amp;lt; this.list._size&lt;/FONT&gt;&lt;FONT color=#000000&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;FONT color=#000000&gt;.current = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.list._items[&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.index];)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;FONT color=#000000&gt;.index++;
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return true&lt;/FONT&gt;&lt;FONT color=#000000&gt;;
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;FONT color=#000000&gt;.index = &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.list._size + 1;
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;&lt;FONT color=#000000&gt;.current = &lt;FONT color=#0000ff&gt;default&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;);
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return false&lt;/FONT&gt;&lt;FONT color=#000000&gt;;
&lt;/FONT&gt;}
&lt;/FONT&gt;
public void&lt;/FONT&gt; SumUpMeaningDemo()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; magicNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[] { 7, 13, 1000, 42, 9 });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; total = 0;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// What you write:
&amp;nbsp;&amp;nbsp;&amp;nbsp;// foreach (int number in magicNumbers)
&amp;nbsp;&amp;nbsp;&amp;nbsp;// {
&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total += number;
&amp;nbsp;&amp;nbsp;&amp;nbsp;// }&lt;/FONT&gt;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// What you get:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt;.Enumerator enumerator = (&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt;.Enumerator)magicNumbers.&lt;STRONG&gt;GetEnumerator()&lt;/STRONG&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;try&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;while&lt;/FONT&gt;(enumerator.&lt;STRONG&gt;MoveNext()&lt;/STRONG&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; temp = enumerator.&lt;STRONG&gt;Current&lt;/STRONG&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total += temp;
&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;FONT color=#0000ff&gt;finally&lt;/FONT&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;enumerator.&lt;STRONG&gt;Dispose()&lt;/STRONG&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/PRE&gt;
&lt;P&gt;There are four different calls in the above code that are marked in bold.&amp;nbsp; Here's the equivalent of what you end up with if you use the &lt;CODE&gt;List&amp;lt;T&amp;gt;.ForEach()&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;private void&lt;/FONT&gt; CompilerGeneratedAnonymousDelegateClass()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public int&lt;/FONT&gt; total;

&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private void&lt;/FONT&gt; CompilerGeneratedDelegateMethod(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; number)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;.total += number;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}

&lt;FONT color=#008000&gt;// For reference, this is the code in List&amp;lt;int&amp;gt;&lt;T&gt;.ForEach():&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; ForEach(&lt;FONT color=#008080&gt;Action &lt;/FONT&gt;action)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (action == &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// throw;&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;for&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; i = 0; i &amp;lt; &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;._size; ++i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;action&lt;/STRONG&gt;(&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;._items[i];)
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}

&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; SumUpMeaningDemo()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; magicNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[] { 7, 13, 1000, 42, 9 });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; total = 0;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// What you write:
&amp;nbsp;&amp;nbsp;&amp;nbsp;// int total = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;// magicNumbers.ForEach(delegate(int number){ total += number; });&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;total += number;
&lt;/FONT&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// What you get (plus the compiler generated class above):&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;CompilerGeneratedAnonymousDelegateClass tempClass = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; CompilerGeneratedAnonymousDelegateClass();
&amp;nbsp;&amp;nbsp;&amp;nbsp;tempClass.total = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;magicNumbers.&lt;STRONG&gt;ForEach&lt;/STRONG&gt;((&lt;FONT color=#008080&gt;Action&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt; &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;Action&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(tempClass.CompilerGeneratedDelegateMethod));
}&lt;/PRE&gt;
&lt;P&gt;There are two calls (in bold, again) and two classes being constructed (the action delegate and the compiler generated class).&amp;nbsp; The easiest way to differentiate the two methods is to look at the size of the resulting code.&amp;nbsp; If you tear into the IL you'll see that in the loop for your &lt;CODE&gt;.ForEach&lt;/CODE&gt; you have 53 IL bytes and &lt;EM&gt;one&lt;/EM&gt; call.&amp;nbsp; The standard &lt;CODE&gt;foreach&lt;/CODE&gt;?&amp;nbsp; &lt;EM&gt;174&lt;/EM&gt; IL bytes and &lt;EM&gt;two&lt;/EM&gt; calls.&amp;nbsp; We could go further into it, but that should make it more than clear.&lt;/P&gt;
&lt;P&gt;Ugh, sorry about all that.&amp;nbsp; That took way more 'splaining than I expected at first.&amp;nbsp; But I couldn't leave an open-ended question now, could I? ;)&lt;/P&gt;
&lt;P&gt;Ok, where was I?&amp;nbsp; Oh yes, the last two types.&amp;nbsp; Here is the signature of Comparison&amp;lt;T&amp;gt;:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public delegate int&lt;/FONT&gt; &lt;CODE&gt;Comparison&amp;lt;T&amp;gt;(T x, T y)&lt;/CODE&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Its used (no suprises here) on the &lt;CODE&gt;Sort&amp;lt;T&amp;gt;()&lt;/CODE&gt; call.&amp;nbsp; The one thing you need to know that isn't obvious is that your method must return the following:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;x &amp;lt; y (return less than zero)&lt;/LI&gt;
&lt;LI&gt;x == y (return zero)&lt;/LI&gt;
&lt;LI&gt;x &amp;gt; y (return greater than zero)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;And now the last delegate type.&amp;nbsp; Here is the signature of &lt;CODE&gt;Converter&amp;lt;T, U&amp;gt;&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public delegate &lt;/FONT&gt;TOutput Converter&amp;lt;TInput, TOutput&amp;gt;(TInput i);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Its used with the &lt;CODE&gt;ConvertAll&amp;lt;TOutput&amp;gt;()&lt;/CODE&gt; call.&amp;nbsp; In the case of &lt;/CODE&gt;List&amp;lt;T&amp;gt;&lt;/CODE&gt;, this method returns a new &lt;CODE&gt;List&amp;lt;TOutput&amp;gt;.&amp;nbsp;&lt;/CODE&gt; There is nothing to say that &lt;CODE&gt;TInput&lt;/CODE&gt; and &lt;CODE&gt;TOutput&lt;/CODE&gt; can't be the same type.&amp;nbsp; This could be useful for doing something like uppercasing a &lt;CODE&gt;List&amp;lt;string&amp;gt;.&lt;/CODE&gt; (Why not use &lt;CODE&gt;ForEach&lt;/CODE&gt;?&amp;nbsp; Just like &lt;CODE&gt;foreach&lt;/CODE&gt; you're working on a &lt;EM&gt;copy&lt;/EM&gt;.)&amp;nbsp; Here's&amp;nbsp;the line of code to upper case a&amp;nbsp;&lt;CODE&gt;List&amp;lt;string&amp;gt;&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;myStringList = myStringList.ConvertAll&amp;lt;&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;delegate&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; item) { &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; item.ToUpper(); };&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;That gets us through the &lt;CODE&gt;System&lt;/CODE&gt; delegate types.&amp;nbsp; That leads us to subclassing.&amp;nbsp; And me running out of time (sorry, disassembling the foreach example took longer than I expected).&amp;nbsp; So, until next time...&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=442602" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Generic Collections II</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/07/23/generic-collections-ii.aspx</link><pubDate>Sat, 23 Jul 2005 03:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:442148</guid><dc:creator>jkuhne</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/442148.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=442148</wfw:commentRss><description>&lt;P&gt;In yesterday's &lt;a href="http://blogs.msdn.com/jeremykuhne/archive/2005/07/22/441676.aspx"&gt;post&lt;/A&gt; I went over the very basics of generic collections in the 2.0 .Net framework.&amp;nbsp; Today I pick up where I left off with...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial size=4&gt;Predicate&amp;lt;T&amp;gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;&lt;A href="http://msdn2.microsoft.com/library/bfcke1bz(en-us,vs.80).aspx"&gt;System.Predicate&amp;lt;T&amp;gt;&lt;/A&gt;&lt;/CODE&gt; is a generic delegate that is used to specify a search condition method to pass to the generic collections.&amp;nbsp; It simply takes an object of type &amp;lt;T&amp;gt; and returns a &lt;CODE&gt;&lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;&lt;/CODE&gt; or &lt;CODE&gt;&lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;&lt;/CODE&gt; if that object meets a condition that the method expects.&amp;nbsp; The definition is quite simple:&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public delegate bool&lt;/FONT&gt; Predicate&amp;lt;T&amp;gt;(T obj);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;Here's another (perhaps easier)&amp;nbsp;way to explain it:&amp;nbsp; When you use the&amp;nbsp;&lt;CODE&gt;List&amp;lt;T&amp;gt;.Find()&lt;/CODE&gt; method, it needs to know what you wish to find.&amp;nbsp; It accomplishes this by taking a &lt;CODE&gt;Predicate&amp;lt;T&amp;gt;&lt;/CODE&gt; parameter that it then calls with each element in the collection to essentially ask "Is this it?&amp;nbsp; No?&amp;nbsp; Is this it? ..."&amp;nbsp; Here's how&amp;nbsp;&lt;CODE&gt;List&amp;lt;T&amp;gt;.Find()&lt;/CODE&gt; actually looks in code:&lt;/P&gt;&lt;PRE&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; T Find(&lt;FONT color=#008080&gt;Predicate&lt;/FONT&gt;&amp;lt;T&amp;gt; match)
{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (match == &lt;FONT color=#0000ff&gt;null&lt;/FONT&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// throw here...&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Iterate through the collection and return the first object that passes the specified predicate.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; i = 0; i &amp;lt; &lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;._size; ++i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (match(&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;._items[i]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;FONT color=#0000ff&gt;return this&lt;/FONT&gt;._items[i];
&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;FONT color=#008000&gt;// Nothing found, return the default object for this type.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return default&lt;/FONT&gt;(T);
}
&lt;/PRE&gt;
&lt;P&gt;Pretty simple actually.&amp;nbsp; The one thing you may not have encountered here is &lt;A href="http://msdn2.microsoft.com/library/xwth0h0d(en-us,vs.80).aspx"&gt;&lt;CODE&gt;&lt;STRONG&gt;default(T)&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/A&gt;.&amp;nbsp; This is a new construct with generics that returns &lt;CODE&gt;null&lt;/CODE&gt; for reference types, zero for numeric value types, and structs with their fields initialized appropriately to &lt;CODE&gt;null&lt;/CODE&gt; or zero.&amp;nbsp; The equivalent in C++ is to simply use &lt;CODE&gt;T()&lt;/CODE&gt;.&amp;nbsp; (note: &lt;CODE&gt;null&lt;/CODE&gt; in C++ is &lt;CODE&gt;nullptr&lt;/CODE&gt;)&lt;/P&gt;
&lt;P&gt;Let's take a look at a sample of &lt;CODE&gt;Predicate&amp;lt;T&amp;gt;&lt;/CODE&gt; in action:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#008000&gt;// Our method that we'll use as a predicate.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;static public bool&lt;/FONT&gt; IsMeaningOfLife(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; number)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; number == 42;
}

&lt;FONT color=#008000&gt;// Elsewhere …&lt;/FONT&gt;

&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; FindMeaningDemo()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; magicNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[] { 7, 13, 1000, 42, 9 });

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Create the predicate delegate&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;System.&lt;FONT color=#008080&gt;Predicate&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; findMeaning = IsMeaningOfLife;

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Does the meaning of life exist in my magic numbers?&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (magicNumbers.Exists(findMeaning))
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#008000&gt;// This will be hit!&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;Console&lt;/FONT&gt;.WriteLine("I've found my purpose!");
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
&lt;/PRE&gt;
&lt;P&gt;&lt;CODE&gt;Exists()&lt;/CODE&gt;, as you may well imagine, simply returns true if the delegate passes on any of the items in the collection.&amp;nbsp; Not too shabby, but this gets even better with...&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=4&gt;&lt;STRONG&gt;&lt;U&gt;Anonymous Delegates&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Anonymous delegates are a C# (sorry C++) &lt;EM&gt;compiler&lt;/EM&gt; feature that allows you to write code blocks in place of a delegate parameter.&amp;nbsp; The compiler will automatically create the proper type of delegate for you.&amp;nbsp; Simply replace the delegate parameter with:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;delegate&amp;nbsp;&lt;/FONT&gt;(&lt;EM&gt;optional arguments&lt;/EM&gt;) { &lt;EM&gt;...code...&lt;/EM&gt; }&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;If we redo the previous example using anonymous delegates we get the following:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; AnonymousFindMeaningDemo()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; magicNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[] { 7, 13, 1000, 42, 9 });

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Does the meaning of life exist in my magic numbers?&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (magicNumbers.Exists(&lt;FONT color=#0000ff&gt;delegate&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; number){ &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; number == 42; }))
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#008000&gt;// This will be hit!&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;Console&lt;/FONT&gt;.WriteLine("I've found my purpose!");
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/PRE&gt;
&lt;P&gt;This, my friends, is where the generic collections start to really show their power.&amp;nbsp; And it gets even better.&amp;nbsp; (No, really!)&amp;nbsp; Ends up you can transparently create a delegate out of an existing variable instance:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public void&lt;/FONT&gt; AnonymousFindMeaningDemo2(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; meaning)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;&lt;INT&gt; magicNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[] { 7, 13, 1000, 42, 9 });

&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Does the meaning of life exist in my magic numbers?&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (magicNumbers.Exists(meaning.Equals))
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#008000&gt;// This will be hit (IF the method was sent one of the numbers in the collection)!&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;Console&lt;/FONT&gt;.WriteLine("I've found my purpose!");
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&lt;/PRE&gt;
&lt;P&gt;Ok, this is somewhat contrived to fit the existing example, but you can hopefully see where this could be really useful.&amp;nbsp; (Have I mentioned that I love this stuff?&amp;nbsp; This just rocks.)&lt;/P&gt;
&lt;P&gt;(Links to more details on anonymous delegates can be found&amp;nbsp;in yesterday's &lt;a href="http://blogs.msdn.com/jeremykuhne/archive/2005/07/22/441676.aspx"&gt;post&lt;/A&gt;.)&lt;/P&gt;
&lt;P&gt;Now, sadly, C++ doesn't support anonymous delegates, but I'll share a cool thing that I just haven't been able to do in C# (yet).&amp;nbsp; For your predicate argument you can take advantage of the System::Predicate constructor that takes an object and a method pointer.&amp;nbsp; Try this on:&amp;nbsp; &lt;CODE&gt;(&lt;FONT color=#0000ff&gt;gcnew&lt;/FONT&gt; System::Predicate&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;^&amp;gt;(42, &amp;amp;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;::Equals))&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Hopefully this has been useful so far, but there is more...&amp;nbsp; In my next post I'll discuss subclassing and the other System delegate types.&amp;nbsp; Stay tuned and feel free to send me your feedback...&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=442148" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Generic Collections I</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/07/22/generic-collections-i.aspx</link><pubDate>Fri, 22 Jul 2005 07:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:441676</guid><dc:creator>jkuhne</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/441676.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=441676</wfw:commentRss><description>&lt;P&gt;In one of my first posts I briefly mentioned that I would discuss a bit about what I've learned about using the new generic collections.&amp;nbsp; I've been putting it off a bit because I knew it would be a bit lengthy, but I really feel this is important so I'm going to push myself to start making the effort. ;)&amp;nbsp; Here's what I plan to cover (in relation to generic collections):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Advantages of generic collections 
&lt;LI&gt;Predicates &amp;amp; other System delegate types 
&lt;LI&gt;Anonymous delegates 
&lt;LI&gt;Subclassing generic collections 
&lt;LI&gt;Other resources (including Power Collections)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I'm &lt;STRONG&gt;not&lt;/STRONG&gt; going to go over generics.&amp;nbsp; If you want details on generics here are a few links:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/en-us/dnvs05/html/csharp_generics.asp?frame=true"&gt;An Introduction to C# Generics&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vs2005icons.asp"&gt;Introducing Generics in the CLR&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vs2005icons.asp"&gt;More on Generics in the CLR&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.15seconds.com/issue/031024.htm"&gt;Introducing .NET Generics&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/512aeb7t(en-us,vs.80).aspx"&gt;Generics (C# Programmer's Reference)&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/8z2kbc1y(en-us,vs.80).aspx"&gt;Generics (C++)&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;I also won't go over anonymous delegates in detail.&amp;nbsp; You can find some useful information here:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/msdnmag/issues/04/05/C20"&gt;C# 2.0: Create Elegant Code with Anonymous Methods, Iterators, and Partial Classes&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/0yw3tz5k(en-us,vs.80).aspx"&gt;Anonymous Methods (C# Programmers Reference)&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=4&gt;&lt;STRONG&gt;&lt;U&gt;Introduction&lt;/U&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Generic collections are the generic equivalents (I like to think of them as &lt;EM&gt;replacements&lt;/EM&gt;) for the &lt;A href="http://msdn2.microsoft.com/library/k166wx47(en-us,vs.80).aspx"&gt;System.Collections&lt;/A&gt; classes.&amp;nbsp; They are found in the &lt;A href="http://msdn2.microsoft.com/library/0sbxh9x2(en-us,vs.80).aspx"&gt;System.Collections.Generic&lt;/A&gt; space.&lt;/P&gt;
&lt;P&gt;Generic collections have a number of advantages over the old collections.&amp;nbsp; Chief among them are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;They are type safe. 
&lt;LI&gt;Better performance.&amp;nbsp; (no boxing/unboxing!) 
&lt;LI&gt;Richer functionality through System defined delegate types.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;To top it off they are quite compatible with the old collections and methods that use them.&amp;nbsp; Both &lt;A href="http://msdn2.microsoft.com/library/7x4b0a97(en-us,vs.80).aspx"&gt;ArrayList&lt;/A&gt; and &lt;A href="http://msdn2.microsoft.com/library/6sh2ey19(en-us,vs.80).aspx"&gt;List&amp;lt;T&amp;gt;&lt;/A&gt; &amp;nbsp;support IList, ICollection, IEnumerable, and ICloneable for example.&amp;nbsp; If existing methods use the old interfaces for parameters there is nothing extra you have to do to start using the generic collections.&amp;nbsp;&amp;nbsp; (Hey, look! A &lt;EM&gt;great&lt;/EM&gt; reason to take the interface (IList)&amp;nbsp;as a parameter instead of the collection class (ArrayList).)&amp;nbsp; Converting is easy beyond this as the old collections&amp;nbsp;take ICollection or IDictionary&amp;nbsp;as a constructor parameter.&lt;/P&gt;
&lt;P&gt;Here's a quick overview of how the new collections map to old ones (from: &lt;A href="http://msdn2.microsoft.com/library/ac30fak4(en-us,vs.80).aspx"&gt;Generics in the .NET Framework Class Library (C# Programmers Reference)&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoNormalTable style="BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 border=0&gt;
&lt;TBODY&gt;
&lt;TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: #e0dfe3; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; BACKGROUND: #cccccc; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #e0dfe3" vAlign=bottom&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Generic Class or Interface&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #e0dfe3; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; BACKGROUND: #cccccc; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #e0dfe3" vAlign=bottom&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Description&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #e0dfe3; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; BACKGROUND: #cccccc; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #e0dfe3" vAlign=bottom&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;B&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Corresponding Non-Generic Type&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 1"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Collection&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;ICollection&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Provides the base class for a generic collection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #cccccc 1pt solid; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;CollectionBase&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;ICollection&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 2"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Comparer&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IComparer&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IComparable&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Compares two objects of the same generic type for equivalence and for sorting.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Comparer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IComparer&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IComparable&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 3"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Dictionary&amp;lt;K, V&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IDictionary&amp;lt;K,V&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a collection of key/value pairs that are organized based on the key.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Hashtable&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IDictionary&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 4"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Dictionary&amp;lt;K, V&amp;gt;.KeyCollection &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents the collection of keys in a Dictionary&amp;lt;K, V&amp;gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;None.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 5"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Dictionary&amp;lt;K, V&amp;gt;.ValueCollection &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents the collection of values in a Dictionary&amp;lt;K, V&amp;gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;None.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 6"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IEnumerable&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IEnumerator&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a collection that can be iterated using &lt;SPAN class=languagekeyword1&gt;&lt;SPAN style="FONT-FAMILY: Arial"&gt;foreach&lt;/SPAN&gt;&lt;/SPAN&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IEnumerable&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IEnumerator&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 7"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;KeyedCollection&amp;lt;T, U&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a keyed collection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;KeyedCollection&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 8"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;LinkedList&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a doubly linked list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;None.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 9"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;LinkedListNode&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a node in a LinkedList&amp;lt;T&amp;gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;None.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 10"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;List&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IList&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Implements the IList&amp;lt;T&amp;gt; interface using an array whose size is dynamically increased as required.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;ArrayList&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;IList&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 11"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Queue&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a first-in, first-out collection of objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Queue&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 12"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;ReadOnlyCollection&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Provides the base class for a generic read-only collection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;ReadOnlyCollectionBase&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 13"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;SortedList&amp;lt;K, V&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a collection of key/value pairs that are sorted by key based on the associated IComparer&amp;lt;T&amp;gt; implementation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;SortedList&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR style="mso-yfti-irow: 14; mso-yfti-lastrow: yes"&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #cccccc 1pt solid; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Stack&amp;lt;T&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Represents a simple last-in-first-out (LIFO) collection of objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD style="BORDER-RIGHT: #cccccc 1pt solid; PADDING-RIGHT: 3.75pt; BORDER-TOP: #e0dfe3; PADDING-LEFT: 3.75pt; PADDING-BOTTOM: 3.75pt; BORDER-LEFT: #e0dfe3; PADDING-TOP: 3.75pt; BORDER-BOTTOM: #cccccc 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid #CCCCCC .75pt; mso-border-left-alt: solid #CCCCCC .75pt; mso-border-top-alt: solid #CCCCCC .75pt" vAlign=top&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: 140%"&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; LINE-HEIGHT: 140%; FONT-FAMILY: Arial"&gt;Stack&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&lt;FONT face=Arial size=4&gt;First Look at a Generic Collection Class&lt;/FONT&gt;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The best place to start is to look at the workhorse of the generic collection family, the generic List class, or List&amp;lt;T&amp;gt;.&amp;nbsp; List&amp;lt;T&amp;gt; is meant to replace the functionality of ArrayList.&amp;nbsp; It is a simple ordered collection of objects of type &amp;lt;T&amp;gt;.&amp;nbsp; You can think of it as a wrapped array because that's precisely what it is--internally data is stored as &lt;CODE&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; T[] _items&lt;/STRONG&gt;;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;As with any array, appending is usually fast (unless the array is being resized) and insertion gets proportionally slower as the number of elements grows.&amp;nbsp; I've already mentioned that it supports &lt;A href="http://msdn2.microsoft.com/library/30ft6hw7(en-us,vs.80).aspx"&gt;IList&lt;/A&gt;, &lt;A href="http://msdn2.microsoft.com/library/b1ht6113(en-us,vs.80).aspx"&gt;ICollection&lt;/A&gt;, and &lt;A href="http://msdn2.microsoft.com/library/h1x9x1b1(en-us,vs.80).aspx"&gt;IEnumerable&lt;/A&gt;.&amp;nbsp; It also supports the generic equivalents&amp;nbsp;&lt;A href="http://msdn2.microsoft.com/library/5y536ey6(en-us,vs.80).aspx"&gt;IList&amp;lt;T&amp;gt;&lt;/A&gt;, &lt;A href="http://msdn2.microsoft.com/library/92t2ye13(en-us,vs.80).aspx"&gt;ICollection&amp;lt;T&amp;gt;&lt;/A&gt;, and &lt;A href="http://msdn2.microsoft.com/library/9eekhta0(en-us,vs.80).aspx"&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Lets take a look at some simple usage of List&amp;lt;T&amp;gt;, shall we?&amp;nbsp; (Finally, some code!)&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;&lt;FONT color=#008000&gt;// Creating a List&amp;lt;T&amp;gt; (Also has constructors that take a collection or specify the initial size)&lt;/FONT&gt;
&lt;/FONT&gt;&lt;FONT color=#008080&gt;List&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt; myNumbers = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; List&amp;lt;&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt;&amp;gt;();&lt;BR&gt;
&lt;FONT color=#008000&gt;// Adding a value&lt;/FONT&gt;
myNumbers.Add(42);&lt;BR&gt;
&lt;FONT color=#008000&gt;// Adding a range of values&lt;/FONT&gt;
myNumbers.AddRange(&lt;FONT color=#0000ff&gt;new int&lt;/FONT&gt;[]{1,2,3});&lt;BR&gt;
&lt;FONT color=#008000&gt;// Inserting a value&lt;/FONT&gt;
myNumbers.Insert(myNumbers.Count - 3, 0);&lt;BR&gt;
&lt;FONT color=#008000&gt;// Iterating&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;foreach&lt;/FONT&gt; (&lt;FONT color=#0000ff&gt;int &lt;/FONT&gt;number in myNumbers)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Output is 42, 0, 1, 2, 3&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008080&gt;Console&lt;/FONT&gt;.WriteLine(number.ToString());
}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code above should be pretty self explanatory.&amp;nbsp; Here is a summary of the functionality that is available to you in List&amp;lt;T&amp;gt;:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Add or insert objects of collections of type T 
&lt;LI&gt;Removal 
&lt;UL&gt;
&lt;LI&gt;Remove, RemoveAt, RemoveRange, RemoveAll&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Sorting 
&lt;UL&gt;
&lt;LI&gt;Sort (&lt;STRONG&gt;Comparison&amp;lt;T&amp;gt;&lt;/STRONG&gt;) 
&lt;LI&gt;Reverse&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Conversion 
&lt;UL&gt;
&lt;LI&gt;ConvertAll (&lt;STRONG&gt;Converter&amp;lt;T,U&amp;gt;&lt;/STRONG&gt;) 
&lt;LI&gt;CopyTo(T[])&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Searching (&lt;STRONG&gt;Predicate&amp;lt;T&amp;gt;&lt;/STRONG&gt;) 
&lt;UL&gt;
&lt;LI&gt;Exists 
&lt;LI&gt;Find, FindAll, FindLast 
&lt;LI&gt;FindIndex, FindLastIndex, IndexOf, LastIndexOf 
&lt;LI&gt;TrueForAll&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Iterating 
&lt;UL&gt;
&lt;LI&gt;ForEach (&lt;STRONG&gt;Action&amp;lt;T&amp;gt;&lt;/STRONG&gt;)&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In bold you will see that I've called out the System delegate types.&amp;nbsp; They are the key to unlocking super rich functionality within these classes.&amp;nbsp; This makes a nice transition to my next blog entry where I'll start by taking a look at Predicate&amp;lt;T&amp;gt; and then this discussion will get &lt;EM&gt;really&lt;/EM&gt; interesting. :)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=441676" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/.NET/default.aspx">.NET</category></item><item><title>C# or C++?</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/06/12/428478.aspx</link><pubDate>Mon, 13 Jun 2005 00:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:428478</guid><dc:creator>jkuhne</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/428478.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=428478</wfw:commentRss><description>&lt;P&gt;I just read &lt;a href="http://blogs.msdn.com/texblog/archive/2005/06/02/424588.aspx"&gt;C++ vs. C#&lt;/A&gt; and thought it might be worthwhile to throw up a few thoughts.&amp;nbsp; I've been ranting and raving about how great the new Managed C++ (C++/CLI) is.&amp;nbsp;&amp;nbsp;It's true, it is great, but I still prefer to do most of my work in C#.&amp;nbsp; Why?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;C# compiles incredibly fast.&amp;nbsp; I'm compiling around 80,000 lines and it takes about 20 seconds for a rebuild.&amp;nbsp; That's from a cold start.&amp;nbsp; (Chokes a little bit starting up intellisense.) 
&lt;LI&gt;Partial classes.&amp;nbsp; Code is so much more maintainable when you have many nested classes.&amp;nbsp; (#include just doesn't compare as a solution.) 
&lt;LI&gt;Anonymous delegates.&amp;nbsp; An incredible feature&amp;nbsp;for unlocking the power of the new generic collection classes.&amp;nbsp; (posts to come on this.) 
&lt;LI&gt;No headers and no need to declare &lt;EM&gt;before&lt;/EM&gt; you use.&amp;nbsp; Both of these can make some nasty looking code sometimes. 
&lt;LI&gt;&lt;STRIKE&gt;XML Documentation &lt;/STRIKE&gt;(Heh, missed this one when I looked last time, it has been awhile... &lt;A href="http://msdn2.microsoft.com/library/ms177226(en-us,vs.80).aspx"&gt;XML Documentation (C++)&lt;/A&gt;) 
&lt;LI&gt;Constructors can call other constructors in the same class. 
&lt;LI&gt;I'm generally more partial to the way it looks.&amp;nbsp; That's obviously a simple preference.
&lt;LI&gt;Generally speaking people seem to be less afraid of C#.&amp;nbsp; More know it (for managed code) and it's easier to enlist a little extra help on a C# project.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;What do I like about Managed C++ over C#?&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Simple properties.&amp;nbsp; Mmmm.&amp;nbsp; Very nice for rapid prototyping. 
&lt;LI&gt;The hat ^.&amp;nbsp; I like knowing when I've got a managed heap handle. 
&lt;LI&gt;C++ Interop is a much better way to work with unmanaged code if you have to. 
&lt;LI&gt;Mixed assemblies. 
&lt;LI&gt;Easier to get function pointers.&amp;nbsp; (this is sometimes useful when using the generic collections, not a big thing, however)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;If you have to migrate an unmanaged C++ project and want to do it piecemeal, the interop capabilities makes Managed C++&amp;nbsp;the obvious choice.&lt;/P&gt;
&lt;P&gt;(If you have any feedback on what you prefer&amp;nbsp;with either language I'd be happy to hear it.)&lt;/P&gt;
&lt;P&gt;(What about VB?&amp;nbsp; I did a lot with VB6 for awhile, but jumping back and forth between C#, C++, and C++/CLI is enough for my head at the moment.&amp;nbsp; So, no comment.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=428478" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/C_2300_/default.aspx">C#</category></item><item><title>P/Invoke? No way! (Pt. 2)</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/06/12/428417.aspx</link><pubDate>Sun, 12 Jun 2005 18:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:428417</guid><dc:creator>jkuhne</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/428417.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=428417</wfw:commentRss><description>&lt;P&gt;[7/20/05: Additional comment added for Marshal::GetFunctionPointerForDelegate()]&lt;/P&gt;
&lt;P&gt;There are some instances where Win32 requires a callback function pointer.&amp;nbsp; This frequently comes up in Enumeration APIs, such as EnumWindows.&amp;nbsp; In this post we’ll look at some code that makes this possible in Managed C++ (2005 -- C++/CLI).&lt;/P&gt;
&lt;P&gt;One could create an unmanaged callback, but we’ll look at the completely managed route here.&amp;nbsp; (One could also use P/Invoke, but you know how I feel about that, no?)&amp;nbsp; (Don’t forget to read my earlier post on how to set up a C++ project for interop with the Win32 API if you haven’t already.)&lt;/P&gt;
&lt;P&gt;You need to do just a few basic things:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Create a method that matches the desired callback signature. 
&lt;LI&gt;Create a delegate type that matches the above method. 
&lt;LI&gt;Create an instance of the delegate that points to your callback method. 
&lt;LI&gt;Pin the delegate. 
&lt;LI&gt;Convert the delegate into a function pointer. 
&lt;LI&gt;Use it. &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Here’s some sample code:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public ref class&lt;/FONT&gt; Window&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt;:&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Private flag for keeping track of when we're enumerating windows.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;static bool&lt;/FONT&gt; enumeratingWindows = &lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Private list of top level windows;&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; List&amp;lt;IntPtr&amp;gt;^ topLevelWindows = &lt;FONT color=#0000ff&gt;gcnew&lt;/FONT&gt; List&amp;lt;IntPtr&amp;gt;();&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Delegate type for the EnumWindowsProc callback.&lt;BR&gt;&amp;nbsp;&amp;nbsp; // Matches the required signature of the API.&amp;nbsp; Note the use of ‘BOOL’, not ‘bool’.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;delegate&lt;/FONT&gt; BOOL EnumWindowsDelegate(HWND hwnd, LPARAM lParam);&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Private method used for EnumWindows calls.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; BOOL EnumWindowsProc(HWND hwnd, LPARAM lParam)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Not much to this.&amp;nbsp; Note the use of ‘TRUE’, not ‘true’.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Window::topLevelWindows-&amp;gt;Add((IntPtr)hwnd);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; TRUE;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;:&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Returns the top-level window handles.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Will return empty List if currently enumerating.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;static property&lt;/FONT&gt; List&amp;lt;IntPtr&amp;gt;^ TopLevelWindowHandles&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;List&amp;lt;IntPtr&amp;gt;^ get()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; List&amp;lt;IntPtr&amp;gt;^ foundWindows = &lt;FONT color=#0000ff&gt;gcnew&lt;/FONT&gt; List&amp;lt;IntPtr&amp;gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (Window::enumeratingWindows == &lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; foundWindows;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Flag that we're currently enumerating windows.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Window::enumeratingWindows = &lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Window::topLevelWindows-&amp;gt;Clear();&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Setup the managed callback.&amp;nbsp; Need to create the delegate we need.&amp;nbsp; (Step 1.)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // &amp;nbsp;(This is a delegate to the managed method defined above.)&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EnumWindowsDelegate^ enumWindowsDelegate = &lt;FONT color=#0000ff&gt;gcnew&lt;/FONT&gt; EnumWindowsDelegate(Window::EnumWindowsProc);&lt;BR&gt;&amp;nbsp;&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Pin the delegate so the GC won’t move it. (Step 2.)&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;pin_ptr&lt;/FONT&gt;&amp;lt;EnumWindowsDelegate^&amp;gt; pinnedDelegate = &amp;amp;enumWindowsDelegate;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Get the function pointer for the delegate and cast it to the type the API expects. (Step 3.)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // 7/20: Note that you can also pass *pinnedDelegate here.  It doesn't matter as they represent the&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // same object.  Having a pin_ptr in scope is what keeps the object itself pinned.&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IntPtr delegatePointer = Marshal::GetFunctionPointerForDelegate(enumWindowsDelegate);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; WNDENUMPROC enumWindowsProc = &lt;FONT color=#0000ff&gt;static_cast&lt;/FONT&gt;&amp;lt;WNDENUMPROC&amp;gt;(delegatePointer.ToPointer());&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (!EnumWindows(enumWindowsProc, 0))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Failed! Throw appropriate fit here...&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // Add what we found and return them.&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; foundWindows-&amp;gt;AddRange(Window::topLevelWindows);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Window::enumeratingWindows = &lt;FONT color=#0000ff&gt;false&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; foundWindows;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;};&lt;P&gt;&lt;/P&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;No unmanaged code used, no P/Invoke, I like it. :)&amp;nbsp; Hopefully you’ll find it useful too.&lt;/P&gt;
&lt;P&gt;Some other potentially useful links:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.codeproject.com/managedcpp/cbwijw.asp"&gt;Implementing Callback functions using IJW (avoiding DllImport)&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://www.developer.com/net/cplus/article.php/3510471"&gt;Using Delegates with Native Function Callbacks in Managed C++&lt;/A&gt; 
&lt;LI&gt;&lt;A href="http://msdn2.microsoft.com/library/367eeye0(en-us,vs.80).aspx"&gt;How to: Marshal Callbacks and Delegates Using C++ Interop&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=428417" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item><item><title>P/Invoke?  No way!</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/06/11/428363.aspx</link><pubDate>Sun, 12 Jun 2005 01:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:428363</guid><dc:creator>jkuhne</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/428363.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=428363</wfw:commentRss><description>&lt;P&gt;[7/20/05: Added an additional comment regarding setting up for Win32]&lt;/P&gt;
&lt;P&gt;I've mentioned in my earlier posts just how nice Managed C++&amp;nbsp; in 2005 (C++/CLI) is when it comes to interoping with unmanaged code.&amp;nbsp; It makes P/Invoke downright painful by comparison. I'd rather toss 10,000 lines of P/Invoke code and restart in C++ than maintain it (and yes, I've done just that).&amp;nbsp; Those legions out there that are using C# (or even VB.Net) shouldn't be afraid of C++ now, the managed syntax is &lt;STRONG&gt;so&lt;/STRONG&gt; much better, it's really quite easy to work with.&amp;nbsp; In this post I'm going to go through some examples of just how easy it is, specifically looking at accessing the Win32 API.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;An example in C# using P/Invoke:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Lets say we want to write a wrapper base class for a window object in Win32.&amp;nbsp; Lets say we want that class to do something relatively simple, like find a specific window by title and stash the handle (HWND) to it, and grab the window's coordinates.&amp;nbsp; Well, first we'd have to define the necessary structs before we could get to defining the P/Invokes:&lt;/P&gt;&lt;PRE&gt;[&lt;STRONG&gt;&lt;FONT color=#000080&gt;StructLayout&lt;/FONT&gt;&lt;/STRONG&gt;(&lt;STRONG&gt;&lt;FONT color=#008080&gt;LayoutKind&lt;/FONT&gt;&lt;/STRONG&gt;.Sequential)]
&lt;FONT color=#0000ff&gt;public struct&lt;/FONT&gt; RECT
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;Int32&lt;/FONT&gt;&lt;/STRONG&gt; left;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;Int32&lt;/FONT&gt;&lt;/STRONG&gt; top;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;Int32&lt;/FONT&gt;&lt;/STRONG&gt; right;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;Int32&lt;/FONT&gt;&lt;/STRONG&gt; bottom;
}&lt;/PRE&gt;&lt;PRE&gt;[&lt;STRONG&gt;&lt;FONT color=#000080&gt;StructLayout&lt;/FONT&gt;&lt;/STRONG&gt;(&lt;STRONG&gt;&lt;FONT color=#008080&gt;LayoutKind&lt;/FONT&gt;&lt;/STRONG&gt;.Sequential)]
&lt;FONT color=#0000ff&gt;public struct&lt;/FONT&gt; WINDOWINFO
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt32&lt;/FONT&gt;&lt;/STRONG&gt; cbSize;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; RECT rcWindow;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; RECT rcClient;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt32&lt;/FONT&gt;&lt;/STRONG&gt; dwStyle;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt32&lt;/FONT&gt;&lt;/STRONG&gt; dwExStyle;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt32&lt;/FONT&gt;&lt;/STRONG&gt; dwWindowStatus;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt32&lt;/FONT&gt;&lt;/STRONG&gt; cxWindowBorders;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt32&lt;/FONT&gt;&lt;/STRONG&gt; cyWindowBorders;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt16&lt;/FONT&gt;&lt;/STRONG&gt; atomWindowType;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color=#008080&gt;UInt16&lt;/FONT&gt;&lt;/STRONG&gt; wCreatorVersion;
}&lt;/PRE&gt;
&lt;P&gt;Hmm, ok.&amp;nbsp; Now the P/Invokes:&lt;/P&gt;&lt;PRE&gt;[&lt;FONT color=#000080&gt;&lt;STRONG&gt;DllImport&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;("user32.dll", SetLastError = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;)]
&lt;FONT color=#0000ff&gt;public static extern &lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;STRONG&gt;Boolean &lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;GetWindowInfo(&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT color=#008080&gt;IntPtr&lt;/FONT&gt;&lt;/STRONG&gt; hwnd;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;out&lt;/FONT&gt; WINDOWINFO pwi);
&lt;U&gt;&lt;/U&gt;&lt;/PRE&gt;&lt;PRE&gt;[&lt;FONT color=#000080&gt;&lt;STRONG&gt;DllImport&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;("user32.dll", SetLastError = &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;true&lt;/FONT&gt;&lt;FONT color=#000000&gt;, CharSet = &lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;STRONG&gt;CharSet&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;.Auto&lt;/FONT&gt;)]
&lt;FONT color=#0000ff&gt;public static extern &lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;STRONG&gt;IntPtr &lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;FindWindow(&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;FONT color=#000080&gt;&lt;STRONG&gt;MarshalAs&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;(&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;STRONG&gt;UnmanagedType&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;.LPTStr)] &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt; lpClassName;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;&lt;FONT color=#000000&gt;[&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color=#000080&gt;MarshalAs&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;(&lt;/FONT&gt;&lt;FONT color=#008080&gt;&lt;STRONG&gt;UnmanagedType&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;.LPTStr)] &lt;/FONT&gt;&lt;FONT color=#0000ff&gt;string&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt; lpWindowName);
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Ugh. Now we can finally call the appropriate APIs.&amp;nbsp; This is a simple example too.&amp;nbsp; It can quickly balloon into a real pain in the ass.&amp;nbsp; Say, when you have an API that takes a #define value for one or more of it's arguments, such as the SendMessage api.&amp;nbsp; You have to find said values, define an enum or constant, and hope desperately you manually copied the value correctly.&amp;nbsp; (When you start doing hundreds or thousands this isn't too difficult to mess up.)&lt;/P&gt;
&lt;P&gt;&lt;U&gt;A few initial humps on the way to the C++ example:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Allright, I may lose some people here, but there are a few things you'll have to do on the C++ side.&amp;nbsp; &lt;A href="http://msdn2.microsoft.com/library/zbz07712(en-us,vs.80).aspx"&gt;Native and .NET Interoperability&lt;/A&gt;&amp;nbsp;describes in detail what you have to do.&amp;nbsp; Usually you don't have to do much of anything.&amp;nbsp; Strings, however, are a little different.&amp;nbsp; (See &lt;A href="http://msdn2.microsoft.com/library/22e4dash(en-us,vs.80).aspx"&gt;How to: Marshal ANSI Strings Using C++ Interop&lt;/A&gt; for complete details--there is a link to Unicode &amp;amp; COM strings from there).&amp;nbsp; I'll give you a small class here that you can use to make this easier (note that I haven't split this up into a header/declaration and a definition for clarity, but I highly recommend it):&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public ref class&lt;/FONT&gt; Convert
{
&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt;:
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Handle for marshalling the unmanged string pointer.
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;IntPtr unmanagedStringPointer;&lt;BR&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Constructor for the managed to native conversion.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Convert(String^ managedString)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this-&amp;gt;unmanagedStringPointer = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(managedString);
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Converts the marshalled pointer to a native string.
&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt;* ToNativeString()
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;static_cast&lt;/FONT&gt;&amp;lt;&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt;*&amp;gt;(this-&amp;gt;unmanagedStringPointer.ToPointer());
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;
&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;:
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Converts a managed string to a native string.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;static char&lt;/FONT&gt;* ToNativeString(String^ managedString)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt;&amp;nbsp;(&lt;FONT color=#0000ff&gt;gcnew&lt;/FONT&gt; Convert(managedString))-&amp;gt;ToNativeString();
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Converts a native string to a managed string.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;static&lt;/FONT&gt; String^ ToString(&lt;FONT color=#0000ff&gt;char&lt;/FONT&gt;* nativeString)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; System::Runtime::InteropServices::Marshal::PtrToStringAnsi(&lt;FONT color=#0000ff&gt;static_cast&lt;/FONT&gt;&amp;lt;IntPtr&amp;gt;(nativeString));
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Destructor (implicitly implements IDisposable)&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;~Convert()
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(this.unmanagedStringPointer != IntPtr::Zero)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System::Runtime::InteropServices::Marshal::FreeHGlobal(this.unmanagedStringPointer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
};&lt;/PRE&gt;
&lt;P&gt;This little helper will make things much easier.&amp;nbsp; You should be able to add Unicode and COM string support by following the previous SDK link.&amp;nbsp; The other thing you'll probably want to do is start adding helpers to convert from common Win32 datatypes to .Net datatypes (say RECT to Rectangle, etc.).&amp;nbsp; You would &amp;nbsp;have to do this in C# as well, of course.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Now for the C++ example:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Again, I won't break this up into a .h and a .cpp file, but this is only for clarity.&amp;nbsp; I'm only using the helper above to convert strings.&amp;nbsp; The rest comes straight from including the Win32 headers.&amp;nbsp; (See the next section for details on how to set that up.)&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;public ref class&lt;/FONT&gt; Window
{
&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt;:
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The native HWND.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;HWND windowHwnd;&lt;BR&gt;
&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;:
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Constructor that takes a window title.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Window(String^ windowTitle)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;HWND foundWindow = FindWindow(NULL, (LPCSTR)Convert::ToNativeString(windowTitle));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (foundWindow == NULL)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// didn't find the window, barf here...&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;else&lt;/FONT&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;-&amp;gt;windowHwnd = foundWindow;
&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;BR&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Returns the bounds of the window in screen coordinates.&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;property&lt;/FONT&gt; Drawing::Rectangle Bounds
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Drawing::Rectangle get()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RECT windowRect;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt; (GetWindowRect(&lt;FONT color=#0000ff&gt;this&lt;/FONT&gt;-&amp;gt;windowHwnd, &amp;amp;windowRect== FALSE)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&lt;FONT color=#008000&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;// Failed somehow.  Deal with it... (Another post.)&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;/FONT&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;return&lt;/FONT&gt; Drawing::Rectangle::FromLTRB(windowRect.left, windowRect.top, windowRect.right, windowRect.bottom);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;/PRE&gt;
&lt;P&gt;And that's it.&amp;nbsp; One small price in setting up a string helper class and you're up and running.&amp;nbsp; I could create the above in a DLL and use it in all my C# projects.&amp;nbsp; (Hey, I do just that.)&amp;nbsp; You can read the Platform SDK and pretty much use it directly.&amp;nbsp; You don't have to set up P/Invokes or redefine structs or #defines.&amp;nbsp; You get intellisense...&amp;nbsp; It's much more freeform to be able to see another useful API and relatively directly be able to use it.&amp;nbsp;&amp;nbsp;For example, when I was constructing my Window class from a specified HWND I noticed there was an API for verifying that a HWND was valid--ok, add one line of code...&lt;/P&gt;
&lt;P&gt;Now, with everything there are always caveats.&amp;nbsp; I have found two circumstances where things don't work seamlessly.&amp;nbsp; If the API has a struct that has a union or bitfields I can't figure out how to access them directly from managed code.&amp;nbsp; (SendInput is an example.)&amp;nbsp;&amp;nbsp; There is a relatively easy workaround and that is to create an unmanaged helper class.&amp;nbsp; That's another post if anyone is interested.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Setting up a Managed C++ project for interop:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Dll, exe, lib, doesn't matter.&amp;nbsp; Here are the key things you need:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;/clr option set for the project.&amp;nbsp; (One of the general settings, see my last post.) 
&lt;LI&gt;Include the appropriate Win32 headers.&amp;nbsp; (&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; &amp;lt;windows.h&amp;gt;&lt;/FONT&gt; is the main one) 
&lt;LI&gt;Appropriate target OS #defines. (see &lt;A href="http://msdn.microsoft.com/library/en-us/winprog/winprog/using_the_windows_headers.asp"&gt;Using the Windows Headers&lt;/A&gt; for the right values)
&lt;LI&gt;[7/20/05] Note that if you have a C++ forms app you'll need to remove $(NoInherit) from the Additional Dependencies property under Linker:Input.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;It's probably a good idea to put the Win32 #includes in a precompiled header for speedier compilation&amp;nbsp;(stdafx.h typically, see &lt;A href="http://msdn.microsoft.com/library/en-us/vccore/html/_core_creating_precompiled_header_files.asp"&gt;Creating Precompiled Header Files&lt;/A&gt; for more info).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=428363" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item><item><title>Acrylic Automation: Crossing the Barrier</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/06/11/428307.aspx</link><pubDate>Sat, 11 Jun 2005 17:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:428307</guid><dc:creator>jkuhne</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/428307.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=428307</wfw:commentRss><description>&lt;P&gt;Ok, so I really was chomping at the bit to blog.&amp;nbsp; Now that we've gone beta I can get a lot of things off of my chest.&amp;nbsp; Just too awkward to blog much before the product was announced, you know?&amp;nbsp; In this post I'm going to give a bit of info on how to write a managed dll that interops with unmanaged code.&amp;nbsp; (FYI: I can't really give the explicit details on how to access the Acrylic automation interfaces at this point.&lt;/P&gt;
&lt;P&gt;This is going to be in Managed C++ in 2005.&amp;nbsp; I've mentioned before that it blows P/Invoking out of the water.&amp;nbsp; The syntax is radically different than the Managed Extensions for C++ that was in VS.Net and is really remarkably easy to read and use for those who know C#, so be strong! ;)&lt;/P&gt;
&lt;P&gt;Making a project managed in C++ is simply a matter of setting the /clr switch, which you can get to in the project properties panel under "Configuration Properties: General: Project Defaults: Common Language Runtime support".&amp;nbsp; There are some variations of this switch that are pretty well documented and I won't go into them here.&amp;nbsp; Our configuration type is "Dynamic Library (.dll)", of course.&amp;nbsp; (This is in the same properties&amp;nbsp;area.)&lt;/P&gt;
&lt;P&gt;We include the standard&amp;nbsp;&amp;lt;windows.h&amp;gt; header and windows version pound defines as we need access to the Win32 api in a number of places.&amp;nbsp; Here's a simplified code snippet that shows you how things work:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#008000&gt;// Plugin.h&lt;/FONT&gt;&lt;BR&gt;
&lt;FONT color=#008000&gt;// You need to include the relevant headers for the interfaces you're trying to hit.&lt;/FONT&gt;
&lt;FONT color=#008000&gt;// This would be defined by the App you're trying to interact with.&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "AppPlugginInterfaceHeaders.h"&lt;BR&gt;
&lt;FONT color=#0000ff&gt;extern&lt;/FONT&gt; "C" &lt;FONT color=#0000ff&gt;// Or "C++" whatever your application uses&lt;/FONT&gt;
{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;/FONT&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The application plugin entry point.&lt;/FONT&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// The __declspec(dllexport) specifies that this function should be exported.&lt;/FONT&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// IApplicationPluginHost is defined in the header provided by the app and included above.&lt;/FONT&gt;
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;__declspec&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;dllexport&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; PluginEntry(IApplicationPluginHost *hostAPIs);
}
&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT color=#008000&gt;// Plugin.cpp&lt;/FONT&gt;&lt;BR&gt;
&lt;P&gt;
&lt;FONT color=#008000&gt;// Or wherever else you have your windows includes if you do..&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "Stdafx.h"
&lt;FONT color=#0000ff&gt;#include&lt;/FONT&gt; "Plugin.h"&lt;BR&gt;
&lt;FONT color=#0000ff&gt;__declspec&lt;/FONT&gt;(&lt;FONT color=#0000ff&gt;dllexport&lt;/FONT&gt;) &lt;FONT color=#0000ff&gt;bool&lt;/FONT&gt; PluginEntry(IApplicationPluginHost *hostAPIs)
{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Code to check and save the interface passed back from the application.&lt;/FONT&gt;
}
&lt;/P&gt;&lt;/PRE&gt;
&lt;P&gt;That's pretty much the sum of it.&amp;nbsp; From there it's using the host api pointer to grab other interfaces and access functions through those interfaces.&amp;nbsp; So something like &lt;FONT face="Courier New"&gt;hostAPIs-&amp;gt;SomeFunction()&lt;/FONT&gt;. We do also have a DllMain (which &lt;EM&gt;must&lt;/EM&gt; be unmanaged according to the SDK) to do some thread initialization that is very app specific in our case.&amp;nbsp; (This would be DLL_THREAD_ATTACH and DLL_THREAD_DETACH message processing.)
&lt;P&gt;In case you're curious, putting completely unmanaged code in your /clr app requires a #pragma managed(push, off) statement before said code and a #pragma managed(pop) afterwords.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=428307" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/All+Things+Acrylic/default.aspx">All Things Acrylic</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item><item><title>VS 2005 Managed C++ Syntax Pt. 1</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/06/10/428218.aspx</link><pubDate>Fri, 10 Jun 2005 23:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:428218</guid><dc:creator>jkuhne</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/428218.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=428218</wfw:commentRss><description>&lt;P&gt;I had very little experience in C++ when I sat down and tried my hand at using Managed C++ in Whidbey last fall (C++/CLI).&amp;nbsp; Documentation was a bit more sparse back then and I found a few things a little difficult to figure out.&amp;nbsp; I've looked again and I still can't easily find the things I struggled with so I thought I'd list them here in the hopes&amp;nbsp;they may be easier for others to find.&lt;/P&gt;
&lt;P&gt;One thing in particular was that I couldn't find anything on was declaring vs. defining methods/functions &amp;amp; properties.&amp;nbsp; Here's a quick example of utilizing the syntax:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#008000&gt;// MyClass.h&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;namespace&lt;/FONT&gt; Sample
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public ref class&lt;/FONT&gt; MyClass
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Property declaration:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;property&lt;/FONT&gt; System::String^ Value { System::String^ get(); &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; set(System::String^ value); }&lt;BR&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Generic method declaration:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;generic&lt;/FONT&gt; &amp;lt;&lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; MyValueType&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;where&lt;/FONT&gt; MyValueType: System::ValueType
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MyValueType GetValue(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; index);
&amp;nbsp;&amp;nbsp;&amp;nbsp;};
}&amp;nbsp;
&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;
&lt;FONT color=#008000&gt;// MyClass.cpp&lt;/FONT&gt;
&lt;FONT color=#0000ff&gt;namespace&lt;/FONT&gt; Sample
{
&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Property definitions:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;System::String^ MyClass::Value::get()
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Getter code here:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;BR&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Property definitions:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;void MyClass::Value::set(System::String^ value)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Setter code here:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&lt;BR&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Generic method definition:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;generic&lt;/FONT&gt; &amp;lt;&lt;FONT color=#0000ff&gt;class&lt;/FONT&gt; MyValueType&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;where&lt;/FONT&gt; MyValueType: System::ValueType
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MyValueType MyClass::GetValue(&lt;FONT color=#0000ff&gt;int&lt;/FONT&gt; index)
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Generic method code here:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}&amp;nbsp;
&lt;/PRE&gt;
&lt;P&gt;You can seperate out the getter/setter declaration if you want to have different accessibility levels for each.&amp;nbsp; Another tricky thing for me was overriding virtual properties:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color=#0000ff&gt;namespace&lt;/FONT&gt; Sample
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public ref class&lt;/FONT&gt; MyBaseClass &lt;FONT color=#0000ff&gt;abstract&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Property declaration (using a simple property):&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;virtual&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;property&lt;/FONT&gt; System::String^ Value;
&amp;nbsp;&amp;nbsp;&amp;nbsp;};
&lt;BR&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public ref class&lt;/FONT&gt; MyDerivedClass : MyBaseClass
&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;public&lt;/FONT&gt;:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#008000&gt;// Property declaration:&lt;/FONT&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;FONT color=#0000ff&gt;property&lt;/FONT&gt; System::String^ Value { &lt;FONT color=#0000ff&gt;virtual&lt;/FONT&gt; System::String^ get() &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt;; &lt;FONT color=#0000ff&gt;virtual&lt;FONT color=#000000&gt; &lt;/FONT&gt;void&lt;/FONT&gt; set(System::String^ value) &lt;FONT color=#0000ff&gt;override&lt;/FONT&gt;; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;};
}&amp;nbsp;
&lt;/PRE&gt;
&lt;P&gt;That's the current syntax (Beta2).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=428218" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item><item><title>Automating Acrylic</title><link>http://blogs.msdn.com/jeremykuhne/archive/2005/06/09/427552.aspx</link><pubDate>Thu, 09 Jun 2005 23:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:427552</guid><dc:creator>jkuhne</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/jeremykuhne/comments/427552.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jeremykuhne/commentrss.aspx?PostID=427552</wfw:commentRss><description>&lt;P&gt;Here's the first of many posts to come out of what I've learned and experienced attempting to automate Acrylic.&lt;/P&gt;
&lt;P&gt;As mentioned before and elsewhere, Microsoft acquired Creature House a few years ago.&amp;nbsp; With this acquisition came the creative design toolset Creature House Expression.&amp;nbsp; We've been working on a new version of the application and one of the challenges I faced in testing the application was finding a way to automate it.&lt;/P&gt;
&lt;P&gt;Acrylic is a pretty large unmanaged codebase (the executable is about 10mb) with a&amp;nbsp;wide&amp;nbsp;variety&amp;nbsp;of features.&amp;nbsp; When I started working on it the application did not have automated tests running against it or an api to write tests against.&amp;nbsp; We intended to change this, but the route to take took some effort to discern. Acrylic has a number of custom controls that aren't actual Windows controls (no HWND of their own).&amp;nbsp; It also has standard Windows controls (in dialogs, mostly).&amp;nbsp; To complicate matters, the application swallows modifier keys in mouse and keyboard messages.&amp;nbsp; We really couldn't use any "off the shelf" solutions.&lt;/P&gt;
&lt;P&gt;An api was added to the application to&amp;nbsp;load&amp;nbsp;&amp;amp; run automation dlls and&amp;nbsp;expose internal state (through interface classes) and provide a method to send modifier keys with input messages.&amp;nbsp; The question as to whether to write unmanaged C++ code directly against this api or put some sort of wrapper layer in to let most of our test code be written in managed code.&lt;/P&gt;
&lt;P&gt;I pushed very hard to write as much of the test automation as possible in managed code.&amp;nbsp; Why?&amp;nbsp; Well, reliable code would be easier to write with the managed safety net.&amp;nbsp; I didn't want to be spending too much time worrying about things like pointer "accidents" in the test code.&amp;nbsp; In addition, there is a great deal of effort and experience being built up with managed tools that take advantage of things like reflection, generics, etc.&amp;nbsp; Another very important thing to me was to be able to easily utilize help from others that could whenever the opportunity arose.&lt;/P&gt;
&lt;P&gt;We did ultimately go with pushing towards mostly managed code.&amp;nbsp; Visual Studio 2005 made this very possible.&amp;nbsp; Here's how we did it:&lt;/P&gt;
&lt;P&gt;We wrote a Managed C++ dll to interface with the internal test interfaces and expose those interfaces in a managed way.&amp;nbsp; Our test libraries and test cases are in seperate dlls (C# mostly, some VB.Net tools).&amp;nbsp; A managed harness kicks off the application with automation enabled (standard shell execute pretty much).&amp;nbsp; The application loads the managed C++ dll (not knowing it is managed) and tells it to kick off tests.&amp;nbsp; The dll tells the test harness to kick off tests.&amp;nbsp;&amp;nbsp; The test harness then starts executing attributed test methods as specified in a configuration file.&lt;/P&gt;
&lt;P&gt;Works like a charm.&amp;nbsp; Writing the interop code in the new managed C++ is incredibly straight forward.&amp;nbsp; It's so straight-forward that once I learned how to really use it I threw out some&amp;nbsp;14,000 lines of Win32 interop code I had written in C# and rewrote the entire thing in managed C++ (made it much better and it took about a week and a half or so).&amp;nbsp; P/Invoke is just way too painful by comparison once you've seen how well the new C++ interops.&lt;/P&gt;
&lt;P&gt;I plan to spend some time here writing about utilizing the new C++ with a particular bent towards interoping with Win32.&amp;nbsp; I'll also talk about other things that I've had to deal with that don't seem too particularly well documented yet (such as the new generic collections and anonymous delegates).&amp;nbsp; If there is anything you're aching to see I'm open to feedback and will direct my efforts towards hitting the things people are interested in.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=427552" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/Managed+C_2B002B00_/default.aspx">Managed C++</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/All+Things+Acrylic/default.aspx">All Things Acrylic</category><category domain="http://blogs.msdn.com/jeremykuhne/archive/tags/General+Coding/default.aspx">General Coding</category></item></channel></rss>