<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CU4HQHk8fip7ImA9WhRbEkk.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102</id><updated>2012-02-02T20:38:51.776-08:00</updated><category term="C#" /><category term="NUnit" /><category term="regex" /><category term="Visual Studio" /><category term="CLR" /><category term="IL" /><category term="SQL" /><category term="HTML" /><category term="ndoc" /><category term=".NET CF" /><category term="boxing" /><category term="Device Development" /><category term="xml documentation" /><category term=".NET" /><category term="OpenGL" /><category term="Serialization" /><title>.NET Enthusiast</title><subtitle type="html">Articles about .NET, C#, ASP.NET, SQL etc.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://dotnet-enthusiast.blogspot.com/" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/netEnthusiast" /><feedburner:info uri="netenthusiast" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DkIGQX85cCp7ImA9WxZXFEQ.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-4344020719500521186</id><published>2008-03-02T13:28:00.000-08:00</published><updated>2008-03-02T13:48:40.128-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-02T13:48:40.128-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title>Custom ORDER BY in SQL</title><content type="html">.NET provides very useful techniques for custom ordering, e.g. generic comparison delegate, lambda expressions, IComparable interface etc.&lt;br /&gt;&lt;br /&gt;When the sort order is needed at database layer, you can use the following statement:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;SELECT &lt;/span&gt;*&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; ContestParticipants&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;ORDER BY&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;CASE&lt;/span&gt; result&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: #a31515;"&gt;'winner'&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 1&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: #a31515;"&gt;'loser'&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 2&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: #a31515;"&gt;'dnf'&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 3&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; 4&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2008%2f03%2fcustom-order-by-in-sql.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2008%2f03%2fcustom-order-by-in-sql.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-4344020719500521186?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/p3qO08EqESFznTISiS698s_JBNM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p3qO08EqESFznTISiS698s_JBNM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/p3qO08EqESFznTISiS698s_JBNM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/p3qO08EqESFznTISiS698s_JBNM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/X4YklQRo-t0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/4344020719500521186/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=4344020719500521186" title="37 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/4344020719500521186?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/4344020719500521186?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/X4YklQRo-t0/custom-order-by-in-sql.html" title="Custom ORDER BY in SQL" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>37</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2008/03/custom-order-by-in-sql.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcAQ3oyeyp7ImA9WxZTGEs.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-2603384960282363843</id><published>2008-01-14T13:50:00.000-08:00</published><updated>2008-01-20T13:54:02.493-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-20T13:54:02.493-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="NUnit" /><title>How to Test Private Fields and Methods using NUnit</title><content type="html">When you write unit tests, you need call some methods and compare their results with expected  values as well as check overall state of objects through fields and properties. It is good to separate tests from testing code. But, what about testing private fields and methods? In addition, tests may be in a standalone assembly. Have a look at the possible ways:&lt;table&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;everything is public&lt;/td&gt;&lt;td&gt;Breaks API&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;private -&gt; internal&lt;/td&gt;&lt;td&gt;Keeps API, but tests must be in the same assmebly&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;&lt;span style="font-weight:bold;"&gt;private -&gt; internal, InternalsVisibleToAttribute&lt;/span&gt;&lt;/td&gt;&lt;td&gt;Keeps API and tests may be in separated assembly&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;The last way is the right one. &lt;code&gt;internal&lt;/code&gt; modifier is clear. Be careful about protected fields, their modifier should be &lt;code&gt;protected internal&lt;/code&gt;. All members are visible within the scope of assembly, but tests are in a separated assembly. What now? The &lt;code&gt;InternalsVisibleToAttribute&lt;/code&gt; comes in handy.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;InternalsVisibleToAttribute&lt;/code&gt; is supported in .NET framework 2.0 and higher. This attribute specifies the "friend assembly" - assembly, that has access to all internal members. So, the last one step is to add the following line to &lt;span style="font-style:italic;"&gt;AssemblyInfo.cs&lt;/span&gt; file:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;[assembly: &lt;span style="color: #2b91af;"&gt;InternalsVisibleTo&lt;/span&gt;(&lt;span style="color: #a31515;"&gt;"FriendAssemblyName, PublicKey=..."&lt;/span&gt;)]&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2008%2f01%2fhow-to-test-private-fields-and-methods.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2008%2f01%2fhow-to-test-private-fields-and-methods.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-2603384960282363843?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/spmptm_I7803UlKy8TV5XxOptvE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/spmptm_I7803UlKy8TV5XxOptvE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/spmptm_I7803UlKy8TV5XxOptvE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/spmptm_I7803UlKy8TV5XxOptvE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/yrHumKWt3xQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/2603384960282363843/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=2603384960282363843" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/2603384960282363843?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/2603384960282363843?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/yrHumKWt3xQ/how-to-test-private-fields-and-methods.html" title="How to Test Private Fields and Methods using NUnit" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2008/01/how-to-test-private-fields-and-methods.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0ICQnw_fCp7ImA9WB9WE0Q.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-5072928708935392058</id><published>2007-11-12T11:25:00.000-08:00</published><updated>2007-11-18T05:12:43.244-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-18T05:12:43.244-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET CF" /><category scheme="http://www.blogger.com/atom/ns#" term="Device Development" /><title>Faster Device Emulator in Visual Studio 2005</title><content type="html">Hurray! There is a new and faster Device Emulator in Visual Studio 2005. Deployment and debugging of .NET Compact Framework apps used to be very slow and tiring. Some bugs were fixed and deployment is significantly faster in Device Emulator ver. 2.0 (&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=DD567053-F231-4A64-A648-FEA5E7061303&amp;amp;displaylang=es&amp;displaylang=en"&gt;download here&lt;/a&gt;). Installer will replace the old version in your Visual Studio.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-5072928708935392058?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/USrUWKv_iD9u_U85zPS76q2OK7s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/USrUWKv_iD9u_U85zPS76q2OK7s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/USrUWKv_iD9u_U85zPS76q2OK7s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/USrUWKv_iD9u_U85zPS76q2OK7s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/iney5Gaq8jU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/5072928708935392058/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=5072928708935392058" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5072928708935392058?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5072928708935392058?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/iney5Gaq8jU/device-emulator-20-in-visual-studio.html" title="Faster Device Emulator in Visual Studio 2005" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/11/device-emulator-20-in-visual-studio.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEANQngzeCp7ImA9WB9WFks.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-6165053043644481038</id><published>2007-09-21T21:40:00.000-07:00</published><updated>2007-11-21T08:33:13.680-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-21T08:33:13.680-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IL" /><category scheme="http://www.blogger.com/atom/ns#" term="boxing" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Boxing Mystery in Overloaded and Overridden Method</title><content type="html">Recently I have produced a code with strange behaviour in my real C# project. Look at this code:&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;BaseMystery&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;int&lt;/span&gt; i) { }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Mystery&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;BaseMystery&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;object&lt;/span&gt; i)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515;"&gt;"Finished."&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;int&lt;/span&gt; i)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; Foo(i);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;Mystery&lt;/span&gt; mystery = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Mystery&lt;/span&gt;();&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; mystery.Foo(3);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;It produces:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;Process is terminated due to StackOverflowException.&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;There is nothing strange. The method &lt;code&gt;Mystery.Foo(int)&lt;/code&gt; is called repeatedly. Then I replaced hidding method &lt;code&gt;Mystery.Foo(int)&lt;/code&gt; by overriding method:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;BaseMystery&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;virtual&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;int&lt;/span&gt; i) { }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Mystery&lt;/span&gt; : &lt;span style="color: #2b91af;"&gt;BaseMystery&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;object&lt;/span&gt; i)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515;"&gt;"Finished."&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;font-weight:bold;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;int&lt;/span&gt; i)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; Foo(i);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main(&lt;span style="color: blue;"&gt;string&lt;/span&gt;[] args)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: #2b91af;"&gt;Mystery&lt;/span&gt; mystery = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Mystery&lt;/span&gt;();&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; mystery.Foo(3);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;And the output is:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;Finished.&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Hah! What is the matter? Let us go to explore IL code of method &lt;code&gt;Mystery.Foo(int)&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;int&lt;/span&gt;)&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;.method &lt;span style="color: blue;"&gt;public&lt;/span&gt; hidebysig instance &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(int32 i) cil managed&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; .maxstack 8&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0000: nop &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0001: ldarg.0 &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0002: ldarg.1 &lt;/p&gt;&lt;p style="margin: 0px;font-weight:bold;"&gt;&amp;nbsp; L_0003: call instance &lt;span style="color: blue;"&gt;void&lt;/span&gt; BoxingMystery.Program/Mystery::Foo(int32)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0008: nop &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0009: ret &lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(&lt;span style="color: blue;"&gt;int&lt;/span&gt;)&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;.method &lt;span style="color: blue;"&gt;public&lt;/span&gt; hidebysig &lt;span style="color: blue;font-weight:bold;"&gt;virtual&lt;/span&gt; instance &lt;span style="color: blue;"&gt;void&lt;/span&gt; Foo(int32 i) cil managed&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; .maxstack 8&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0000: nop &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0001: ldarg.0 &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_0002: ldarg.1 &lt;/p&gt;&lt;p style="margin: 0px;font-weight:bold;"&gt;&amp;nbsp;  L_0003: box int32&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px;font-weight:bold;"&gt;&amp;nbsp; L_0008: call instance &lt;span style="color: blue;"&gt;void&lt;/span&gt; BoxingMystery.Program/Mystery::Foo(object)&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_000d: nop &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; L_000e: ret &lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Argument &lt;code&gt;i&lt;/code&gt; has been boxed. Why? I would expect that the IL body of method &lt;code&gt;Mystery.Foo(int)&lt;/code&gt; will be the same in &lt;span style="font-style:italic;"&gt;new&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;override&lt;/span&gt; declaration but it is different. It is very strange behaviour of compiler. What is your explanation? &lt;br /&gt;&lt;br /&gt;Overridded method in my real project was the right one. In addition, I renamed the methods, because my colleagues could be confused like me.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f09%2fboxing-mystery-in-overloaded-and.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f09%2fboxing-mystery-in-overloaded-and.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-6165053043644481038?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/s7FrkPBFx8-8Qeg5yjtWx6SAggU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/s7FrkPBFx8-8Qeg5yjtWx6SAggU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/s7FrkPBFx8-8Qeg5yjtWx6SAggU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/s7FrkPBFx8-8Qeg5yjtWx6SAggU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/6bck3R6LeH4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/6165053043644481038/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=6165053043644481038" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/6165053043644481038?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/6165053043644481038?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/6bck3R6LeH4/boxing-mystery-in-overloaded-and.html" title="Boxing Mystery in Overloaded and Overridden Method" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/09/boxing-mystery-in-overloaded-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYDQ385fyp7ImA9WxRbF0Q.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-1765206713483393414</id><published>2007-09-17T14:58:00.000-07:00</published><updated>2008-12-08T20:32:52.127-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-08T20:32:52.127-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio" /><category scheme="http://www.blogger.com/atom/ns#" term="NUnit" /><title>Launch NUnit Tests directly from Visual Studio and Debug</title><content type="html">Launching tests directly from Visual Studio is very comfortable feature. Developers, who are familiar with test driven development, need to launch tests frequently, so this feature is necessary for them.&lt;br /&gt;&lt;br /&gt;My favourite testing framework is &lt;a href="http://www.nunit.org"&gt;NUnit&lt;/a&gt;. Tests in this framework are launched from external application with perfect GUI.&lt;br /&gt;&lt;br /&gt;In this article I will demonstrate how to start external application from Visual Studio, e.g. NUnit GUI, and keep running debugger. Debugging NUnit tests is very significant advantage because standard GUI of NUnit framework does not support it.&lt;br /&gt;&lt;br /&gt;So, suppose that you have created a &lt;span style="font-weight:bold;"&gt;class library project&lt;/span&gt; with the following &lt;span style="font-weight:bold;"&gt;NUnit test&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.IO;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; NUnit.Framework;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; NUnit.Framework.SyntaxHelpers;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; DirectNUnit&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; [&lt;span style="color: #2b91af;"&gt;TestFixture&lt;/span&gt;]&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af;"&gt;Tests&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; [&lt;span style="color: #2b91af;"&gt;Test&lt;/span&gt;]&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Test()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt; combinedPath = &lt;span style="color: #2b91af;"&gt;Path&lt;/span&gt;.Combine(&lt;span style="color: #a31515;"&gt;@"C:\Projects"&lt;/span&gt;, &lt;span style="color: #a31515;"&gt;@"HelloWorld"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #2b91af;"&gt;Assert&lt;/span&gt;.That(combinedPath, &lt;span style="color: #2b91af;"&gt;Is&lt;/span&gt;.EqualTo(&lt;span style="color: #a31515;"&gt;@"C:\Projects\HelloWorld"&lt;/span&gt;));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now, you want to start this test directly from Visual Studio and use some breakpoints in the test. You can do it without any VS plug-in, just edit project settings. Open &lt;span style="font-style:italic;"&gt;Project | Properties | Debug&lt;/span&gt; and set values like this:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Xkol528oDD8/Ru73kglr5II/AAAAAAAAADo/LXhIJpZwVXA/s1600-h/DirectNUnit.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_Xkol528oDD8/Ru73kglr5II/AAAAAAAAADo/LXhIJpZwVXA/s400/DirectNUnit.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5111294833707443330" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Enter &lt;span style="font-style:italic;"&gt;Start external program&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;Command line arguments&lt;/span&gt;, that is the path to the assembly containing your test.&lt;br /&gt;&lt;br /&gt;For launching NUnit GUI and debugging tests press &lt;span style="font-weight:bold;"&gt;F5&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f09%2flaunch-nunit-tests-directly-from-visual.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f09%2flaunch-nunit-tests-directly-from-visual.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-1765206713483393414?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gKtvL5Ani23CavkqME-e4YQFLgI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gKtvL5Ani23CavkqME-e4YQFLgI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gKtvL5Ani23CavkqME-e4YQFLgI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gKtvL5Ani23CavkqME-e4YQFLgI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/54YjHjLQ0fs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/1765206713483393414/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=1765206713483393414" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/1765206713483393414?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/1765206713483393414?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/54YjHjLQ0fs/launch-nunit-tests-directly-from-visual.html" title="Launch NUnit Tests directly from Visual Studio and Debug" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_Xkol528oDD8/Ru73kglr5II/AAAAAAAAADo/LXhIJpZwVXA/s72-c/DirectNUnit.PNG" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/09/launch-nunit-tests-directly-from-visual.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQGR3w7eip7ImA9WB9VEEs.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-5482163873620306652</id><published>2007-06-11T13:31:00.000-07:00</published><updated>2007-11-26T00:05:26.202-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-26T00:05:26.202-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Currency Format Depending on Culture</title><content type="html">It is usual, that you write an application with GUI for a specified culture and then you suddenly get to know that the application should work with several different currency formats. In the following example I want to demonstrate a very simple method how to change the currency format in your application elegantly and dynamically.&lt;br /&gt;&lt;br /&gt;Ordinarily numbers are formatted as currency by these ways:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;decimal&lt;/span&gt; value = 1234567.89M;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(value.ToString(&lt;span style="color: maroon;"&gt;"C"&lt;/span&gt;));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: green;"&gt;//or&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: maroon;"&gt;"{0:C}"&lt;/span&gt;, value);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: green;"&gt;//or&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: teal;"&gt;String&lt;/span&gt;.Format(&lt;span style="color: maroon;"&gt;"{0:C}"&lt;/span&gt;, value));&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Actually, there are many places like this in your application and you want to change the format depending on user's choice of culture. The following code comes in handy:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Thread&lt;/span&gt;.CurrentThread.CurrentCulture = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;CultureInfo&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"en-us"&lt;/span&gt;);&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;The whole example is:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Threading;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Globalization;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; CurrencyFormat&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;Program&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;decimal&lt;/span&gt; value = 1234567.89M;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Thread&lt;/span&gt;.CurrentThread.CurrentCulture = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;CultureInfo&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"en-US"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: maroon;"&gt;"{0:C}"&lt;/span&gt;, value);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Thread&lt;/span&gt;.CurrentThread.CurrentCulture = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;CultureInfo&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"fr-FR"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: maroon;"&gt;"{0:C}"&lt;/span&gt;, value);&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Thread&lt;/span&gt;.CurrentThread.CurrentCulture = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;CultureInfo&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"ja-JP"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: maroon;"&gt;"{0:C}"&lt;/span&gt;, value);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;$1,234,567.89&lt;/p&gt;&lt;p style="margin: 0px;"&gt;1&amp;#160;234&amp;#160;567,89 &amp;#8364;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;Y1,234,568&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;List of all available culture names and identifiers is on &lt;a href="http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo(vs.80).aspx"&gt;MSDN&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f06%2fcurrency-format-depending-on-culture.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f06%2fcurrency-format-depending-on-culture.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-5482163873620306652?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Sd9Oc8ydpFhtXejRLDqDUzEHusU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Sd9Oc8ydpFhtXejRLDqDUzEHusU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Sd9Oc8ydpFhtXejRLDqDUzEHusU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Sd9Oc8ydpFhtXejRLDqDUzEHusU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/-q73_UETQ1Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/5482163873620306652/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=5482163873620306652" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5482163873620306652?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5482163873620306652?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/-q73_UETQ1Q/currency-format-depending-on-culture.html" title="Currency Format Depending on Culture" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/06/currency-format-depending-on-culture.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYDQ30zeCp7ImA9WxRbF0Q.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-5728278990189785427</id><published>2007-05-24T16:01:00.000-07:00</published><updated>2008-12-08T20:32:52.380-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-08T20:32:52.380-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="HTML" /><title>Syntax-Highlighted Code from Visual Studio as HTML</title><content type="html">Maybe you wondered about syntax-highlighted code in this blog but &lt;code&gt;blogger.com&lt;/code&gt; does not provide any tool for this. If you use Visual Studio, just try this &lt;a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/"&gt;CopySourceAsHtml&lt;/a&gt; add-in.&lt;br /&gt;&lt;br /&gt;CopySourceAsHtml generates HTML source of your syntax-highlighted code in VS. You can select and copy your code as HTML to clipboard, so your syntax-highlighted code can be  placed anywhere.&lt;br /&gt;&lt;br /&gt;Here are my settings of CopySourceAsHtml add-in:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Xkol528oDD8/RlYc-k5OmUI/AAAAAAAAAAw/BWq56O--SoY/s1600-h/CopySourceAsHTMLSettings1.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_Xkol528oDD8/RlYc-k5OmUI/AAAAAAAAAAw/BWq56O--SoY/s400/CopySourceAsHTMLSettings1.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5068270292033247554" /&gt;&lt;/a&gt;&lt;br /&gt;My "File Style" is:&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: red;"&gt;border&lt;/span&gt;:&lt;span style="color: blue;"&gt;1px&lt;/span&gt; &lt;span style="color: blue;"&gt;solid&lt;/span&gt; &lt;span style="color: blue;"&gt;black&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: red;"&gt;padding&lt;/span&gt;: &lt;span style="color: blue;"&gt;8pt&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: red;"&gt;width&lt;/span&gt;: &lt;span style="color: blue;"&gt;94%&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: red;"&gt;overflow&lt;/span&gt;: &lt;span style="color: blue;"&gt;auto&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: red;"&gt;background-color&lt;/span&gt;: &lt;span style="color: blue;"&gt;#F0F0F0&lt;/span&gt;;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Here is an example output:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;HelloWorld&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Main()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: maroon;"&gt;"Hello, World!"&lt;/span&gt;);&amp;nbsp; &amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fsyntax-highlighted-code-from-visual.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fsyntax-highlighted-code-from-visual.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;script&gt;reddit_url='http://dotnet-enthusiast.blogspot.com/2007/05/syntax-highlighted-code-from-visual.html'&lt;/script&gt;&lt;br /&gt;&lt;script&gt;reddit_title='Syntax-Highlighted Code from Visual Studio as HTML'&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript" src="http://reddit.com/button.js?t=1"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-5728278990189785427?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/lb7hA4infgQ6oTDUZROyreiyNQs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lb7hA4infgQ6oTDUZROyreiyNQs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/lb7hA4infgQ6oTDUZROyreiyNQs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lb7hA4infgQ6oTDUZROyreiyNQs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/p8UiCbwCGRE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/5728278990189785427/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=5728278990189785427" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5728278990189785427?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5728278990189785427?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/p8UiCbwCGRE/syntax-highlighted-code-from-visual.html" title="Syntax-Highlighted Code from Visual Studio as HTML" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_Xkol528oDD8/RlYc-k5OmUI/AAAAAAAAAAw/BWq56O--SoY/s72-c/CopySourceAsHTMLSettings1.PNG" height="72" width="72" /><thr:total>5</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/05/syntax-highlighted-code-from-visual.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYDQ3s4fCp7ImA9WxRbF0Q.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-975874304099647327</id><published>2007-05-23T14:39:00.000-07:00</published><updated>2008-12-08T20:32:52.534-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-08T20:32:52.534-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="OpenGL" /><title>OpenGL in .NET</title><content type="html">There is a very simple way how to use OpenGL library in .NET application using C#. The library what you need can be downloaded here &lt;a href="http://csgl.sourceforge.net/"&gt;csgl.sourceforge.net&lt;/a&gt;. The simplest way is to add these downloaded files to your project:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;csgl.dll&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;csgl.native.dll&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;See the following "Hello world!" project step by step.&lt;br /&gt;&lt;br /&gt;Create a new &lt;b&gt;Windows application project&lt;/b&gt;. In the new solution add a new project &lt;b&gt;Class library&lt;/b&gt; named &lt;code&gt;GLViewControl&lt;/code&gt;. Add &lt;code&gt;csgl.dll&lt;/code&gt; and &lt;code&gt;csgl.native.dll&lt;/code&gt; to the &lt;code&gt;GLViewControl&lt;/code&gt; project and reference &lt;code&gt;csgl.dll&lt;/code&gt; library. Reference also &lt;code&gt;System.Windows.Forms&lt;/code&gt; and &lt;code&gt;System.Drawing&lt;/code&gt;.&lt;br /&gt;Set the "Copy to output directory" property for &lt;code&gt;csgl.native.dll&lt;/code&gt; file. Presence of this file in the output directory is important unless you have to install &lt;code&gt;csgl&lt;/code&gt; on each system particularly.&lt;br /&gt;&lt;br /&gt;Now the project is ready for our code. Add a new class in &lt;code&gt;GLViewControl&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; CsGL.OpenGL;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; GLViewControl&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;GLView&lt;/span&gt; : &lt;span style="color: teal;"&gt;OpenGLControl&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; glDraw()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glClear(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_COLOR_BUFFER_BIT | &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_DEPTH_BUFFER_BIT);&lt;span style="color: green;"&gt;// Clear the Screen and the Depth Buffer&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glMatrixMode(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_MODELVIEW); &lt;span style="color: green;"&gt;// Modelview Matrix&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glLoadIdentity();&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;// reset the current modelview matrix&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glTranslatef(0.0f, 0.0f, -4.0f);&amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glBegin(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_POLYGON);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glColor3d(0, 0, 1);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glVertex3f(-1, -1, 0);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glColor3d(0, 1, 0);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glVertex3f(1, -1, 0);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glColor3d(1, 0, 0);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glVertex3f(0, 1, 0);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glEnd(); &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; InitGLContext()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); &lt;span style="color: green;"&gt;// black background&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glClearDepth(1.0f);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="color: green;"&gt;// depth buffer setup&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glEnable(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_DEPTH_TEST);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="color: green;"&gt;// enables depth testing&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glDepthFunc(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_LEQUAL);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="color: green;"&gt;// type of depth testing &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glHint(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_PERSPECTIVE_CORRECTION_HINT, &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_NICEST);&amp;nbsp; &lt;span style="color: green;"&gt;// nice perspective calculations&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnSizeChanged(&lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnSizeChanged(e);&amp;nbsp;  &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glMatrixMode(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_PROJECTION);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glLoadIdentity();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.gluPerspective(45.0f, (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)Size.Width / (&lt;span style="color: blue;"&gt;double&lt;/span&gt;)Size.Height, 0.1f, 100.0f);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glMatrixMode(&lt;span style="color: teal;"&gt;GL&lt;/span&gt;.GL_MODELVIEW);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;GL&lt;/span&gt;.glLoadIdentity();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt; &lt;br /&gt;&lt;br /&gt;And now just drag and drop a new &lt;code&gt;GLView&lt;/code&gt; control from the toolbox in VS on your form and run the application. The result looks like this:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Xkol528oDD8/RlYhK05OmVI/AAAAAAAAAA4/LqLC6QMmpfY/s1600-h/csgl.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_Xkol528oDD8/RlYhK05OmVI/AAAAAAAAAA4/LqLC6QMmpfY/s400/csgl.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5068274900533156178" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fopengl-in-net.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fopengl-in-net.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-975874304099647327?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/R6lliN70khzatRK5DXf0522f2bY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/R6lliN70khzatRK5DXf0522f2bY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/R6lliN70khzatRK5DXf0522f2bY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/R6lliN70khzatRK5DXf0522f2bY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/atYqoghYAcU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/975874304099647327/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=975874304099647327" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/975874304099647327?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/975874304099647327?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/atYqoghYAcU/opengl-in-net.html" title="OpenGL in .NET" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_Xkol528oDD8/RlYhK05OmVI/AAAAAAAAAA4/LqLC6QMmpfY/s72-c/csgl.PNG" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/05/opengl-in-net.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIASH8_eSp7ImA9WxZbGUU.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-3727282886370518601</id><published>2007-05-16T02:18:00.000-07:00</published><updated>2008-04-23T14:02:29.141-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-23T14:02:29.141-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><category scheme="http://www.blogger.com/atom/ns#" term="CLR" /><title>User Defined Aggregate Function in SQL for String Concatenation using CLR</title><content type="html">If you tried to concatenate strings from group in SQL, probably you would start looking for an aggregate function similar to SUM or COUNT. There is no function like this in SQL Server 2005 and even further there is no way how to create a custom aggregate function using SQL. You can use just built-in aggregates.&lt;br /&gt;&lt;br /&gt;Fortunately, SQL Server 2005 integrates common language runtime (CLR). So, the solution is to write an aggregate function in C# and include it among built-in functions in SQL Server.&lt;br /&gt;&lt;br /&gt;Let us show an example with aggregate function for strings concatenation. At first you should create a new project in VS - use template &lt;b&gt;Class Library&lt;/b&gt;, name it for example MyCLRLib.&lt;br /&gt;&lt;br /&gt;The key methods are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;Init()&lt;/code&gt; - initializes private variables&lt;/li&gt;&lt;li&gt;&lt;code&gt;Accumulate()&lt;/code&gt; - appends the next value&lt;/li&gt;&lt;li&gt;&lt;code&gt;Merge()&lt;/code&gt; - merges partial aggregates&lt;/li&gt;&lt;li&gt;&lt;code&gt;Terminates()&lt;/code&gt; - returns a result aggregation&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Here is completed a copy-paste code:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Text;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.IO;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; Microsoft.SqlServer.Server;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Data.SqlTypes;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;[&lt;span style="color: teal;"&gt;Serializable&lt;/span&gt;]&lt;/p&gt;&lt;p style="margin: 0px;"&gt;[&lt;span style="color: teal;"&gt;SqlUserDefinedAggregate&lt;/span&gt;(&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;Format&lt;/span&gt;.UserDefined,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="color: green;"&gt;//use custom serialization to serialize the intermediate result&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; IsInvariantToNulls = &lt;span style="color: blue;"&gt;true&lt;/span&gt;,&amp;nbsp; &lt;span style="color: green;"&gt;//optimizer property&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; IsInvariantToDuplicates = &lt;span style="color: blue;"&gt;false&lt;/span&gt;, &lt;span style="color: green;"&gt;//optimizer property&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; IsInvariantToOrder = &lt;span style="color: blue;"&gt;false&lt;/span&gt;, &lt;span style="color: green;"&gt;//optimizer property&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; MaxByteSize = 8000)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;  &lt;span style="color: green;"&gt;//maximum size in bytes of persisted value&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;]&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;Concatenate&lt;/span&gt; : &lt;span style="color: teal;"&gt;IBinarySerialize&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;// Intermediate result data of concatenation&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: teal;"&gt;StringBuilder&lt;/span&gt; intermediateResult;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Init()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;StringBuilder&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;// If the next value is not null, append it to the end of string&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Accumulate(&lt;span style="color: teal;"&gt;SqlString&lt;/span&gt; value)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (value.IsNull)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt;;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult.Append(value.Value).Append(&lt;span style="color: maroon;"&gt;", "&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;//Merges the partial aggregate with this aggregate&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Merge(&lt;span style="color: teal;"&gt;Concatenate&lt;/span&gt; part)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult.Append(part.intermediateResult);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;//Returns the result of the aggregation when finished&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlString&lt;/span&gt; Terminate()&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt; result = &lt;span style="color: blue;"&gt;string&lt;/span&gt;.Empty;&amp;nbsp; &amp;nbsp; &lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (&lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult != &lt;span style="color: blue;"&gt;null&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult.Length &amp;gt; 0)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; result = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult.ToString(0, &lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult.Length - 1);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlString&lt;/span&gt;(result);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Read(&lt;span style="color: teal;"&gt;BinaryReader&lt;/span&gt; reader)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; intermediateResult = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;StringBuilder&lt;/span&gt;(reader.ReadString());&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Write(&lt;span style="color: teal;"&gt;BinaryWriter&lt;/span&gt; writer)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; writer.Write(&lt;span style="color: blue;"&gt;this&lt;/span&gt;.intermediateResult.ToString());&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Now you can register this function in SQL Server. First of all, enable .NET CLR code execution in your SQL Server:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;EXEC&lt;/span&gt; sp_configure &lt;span style="color: maroon;"&gt;'clr enabled'&lt;/span&gt;, 1;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;RECONFIGURE WITH&lt;/span&gt; OVERRIDE;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;GO&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;and then create new aggregate function from your compiled assembly:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;CREATE ASSEMBLY&lt;/span&gt; MyCLRLib &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: maroon;"&gt;'D:\MyCLRLib.dll'&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;GO&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;CREATE AGGREGATE&lt;/span&gt; Concatenate (@input &lt;span style="color: blue;"&gt;nvarchar&lt;/span&gt;(1000)) &lt;span style="color: blue;"&gt;RETURNS nvarchar&lt;/span&gt;(max)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;EXTERNAL NAME&lt;/span&gt; MyCLRLib.Concatenate&lt;/p&gt;&lt;p style="margin: 0px;"&gt;GO&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Now you can write:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; Surname, dbo.Concatenate(FirstName)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; Families&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;GROUP BY&lt;/span&gt; Surname&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fuser-defined-aggregate-function-in-sql.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fuser-defined-aggregate-function-in-sql.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;script&gt;reddit_url='http://dotnet-enthusiast.blogspot.com/2007/05/user-defined-aggregate-function-in-sql.html'&lt;/script&gt;&lt;br /&gt;&lt;script&gt;reddit_title='User Defined Aggregate Function in SQL for String Concatenation using CLR'&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript" src="http://reddit.com/button.js?t=1"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-3727282886370518601?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/35GXntiylSTPTTZQK8xDjmbcV5I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/35GXntiylSTPTTZQK8xDjmbcV5I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/35GXntiylSTPTTZQK8xDjmbcV5I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/35GXntiylSTPTTZQK8xDjmbcV5I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/kfluGh8Eybw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/3727282886370518601/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=3727282886370518601" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/3727282886370518601?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/3727282886370518601?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/kfluGh8Eybw/user-defined-aggregate-function-in-sql.html" title="User Defined Aggregate Function in SQL for String Concatenation using CLR" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>10</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/05/user-defined-aggregate-function-in-sql.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIDSXk-cSp7ImA9WB9UEUw.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-7412735912246507784</id><published>2007-05-15T14:20:00.000-07:00</published><updated>2007-12-08T03:49:38.759-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-08T03:49:38.759-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><category scheme="http://www.blogger.com/atom/ns#" term="regex" /><title>Regular Expressions in .NET</title><content type="html">There are powerful tools in Unix such as grep, sed etc. These programs make use of regular expressions - regexp. Luckily, .NET contains a very useful class - a &lt;code&gt;Regex&lt;/code&gt; class in a &lt;code&gt;System.Text.RegularExpressions&lt;/code&gt; namespace.&lt;br /&gt;&lt;br /&gt;Before using of regular expressions you need to understand the syntax. Here is a basic:&lt;br /&gt;&lt;table style="width: 537px; height: 247px;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;br /&gt;&lt;td style="width: 50px;"&gt;.&lt;/td&gt;&lt;td&gt;Matches any single character&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;^&lt;/td&gt;&lt;td&gt;Matches the beginning of a string&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;$&lt;/td&gt;&lt;td&gt;Matches the end of a string&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;*&lt;/td&gt;&lt;td&gt;Matches the preceding character or subexpression zero or&lt;br/&gt; more times&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;+&lt;/td&gt;&lt;td&gt;Matches the preceding character or subexpression one or&lt;br/&gt; more times&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;tr&gt;&lt;br /&gt;&lt;td&gt;(  )&lt;/td&gt;&lt;td&gt;subexpression&lt;/td&gt;&lt;br /&gt;&lt;/tr&gt;&lt;br /&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;For more information about &lt;span style="font-weight: bold;"&gt;regular expressions syntax&lt;/span&gt; see this &lt;a href="http://msdn2.microsoft.com/en-us/library/az24scfc%28vs.71%29.aspx"&gt;link&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now I can show how it is being used. The key method is &lt;code&gt;Regex.IsMatch()&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Regex&lt;/span&gt; regex = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;Regex&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"^a...b$"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt; test1 = regex.IsMatch(&lt;span style="color: maroon;"&gt;"axyzb"&lt;/span&gt;);&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;//true&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt; test2 = regex.IsMatch(&lt;span style="color: maroon;"&gt;"axyzxyzb"&lt;/span&gt;); &lt;span style="color: green;"&gt;//false&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;bool&lt;/span&gt; test3 = regex.IsMatch(&lt;span style="color: maroon;"&gt;"d"&lt;/span&gt;);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;//false&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The following example validates an e-mail adress:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Text.RegularExpressions;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;EmailAdress&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: teal;"&gt;Regex&lt;/span&gt; emailRegex = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;Regex&lt;/span&gt;( &lt;span style="color: maroon;"&gt;@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public static&lt;/span&gt; &lt;span style="color: blue;"&gt;bool&lt;/span&gt; Validate(&lt;span style="color: blue;"&gt;string&lt;/span&gt; email)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; emailRegex.IsMatch(email);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;For more information see:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/hs600312.aspx"&gt;.NET Framework Regular Expressions&lt;/a&gt; (MSDN)&lt;br /&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/system.text.regularexpressions.aspx"&gt;System.Text.RegularExpressions Namespace&lt;/a&gt; (MSDN)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fregular-expressions-in-net.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fregular-expressions-in-net.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-7412735912246507784?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/MGGpQrQeh14mu0yfZtn41QPO8SE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MGGpQrQeh14mu0yfZtn41QPO8SE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/MGGpQrQeh14mu0yfZtn41QPO8SE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/MGGpQrQeh14mu0yfZtn41QPO8SE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/yOqC6_rA4CA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/7412735912246507784/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=7412735912246507784" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/7412735912246507784?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/7412735912246507784?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/yOqC6_rA4CA/regular-expressions-in-net.html" title="Regular Expressions in .NET" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/05/regular-expressions-in-net.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIFQHg_cSp7ImA9WxZaFE8.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-5719253525358055549</id><published>2007-05-11T03:56:00.000-07:00</published><updated>2008-04-28T15:08:31.649-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-28T15:08:31.649-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Serialization" /><category scheme="http://www.blogger.com/atom/ns#" term=".NET" /><title>Simple Serialization and Deserialization in C#</title><content type="html">.NET provides a functionality for storing and loading objects. This post shows how it can be used. The mechanism is called serialization and its purpose is to convert any object to stream of bytes that can be saved on a disk, sent by a protocol via internet etc.&lt;br /&gt;&lt;br /&gt;So, at the beginning you have a class which you want to serialize. For example it looks like this:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; name;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; age;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;readonly&lt;/span&gt; &lt;span style="color: teal;"&gt;DateTime&lt;/span&gt; dateOfBirth;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;double&lt;/span&gt;[] score;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; MyExampleClass(&lt;span style="color: blue;"&gt;string&lt;/span&gt; name, &lt;span style="color: blue;"&gt;int&lt;/span&gt; age, &lt;span style="color: teal;"&gt;DateTime&lt;/span&gt; dateOfBirth)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.name = name;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.age = age;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.dateOfBirth = dateOfBirth;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;this&lt;/span&gt;.score = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;double&lt;/span&gt;[0];&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;Now, you want to save object of this class on a disk. At first add some namespaces:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.IO;&amp;nbsp; &amp;nbsp; &lt;span style="color: green;"&gt;//Stream class&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;using&lt;/span&gt; System.Runtime.Serialization.Formatters.Binary;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Add &lt;code&gt;[Serializable]&lt;/code&gt; attribute to your class:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;[&lt;span style="color: teal;"&gt;Serializable&lt;/span&gt;]&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;and then add methods for save and load in &lt;code&gt;MyExampleClass&lt;/code&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; SaveToFile(&lt;span style="color: blue;"&gt;string&lt;/span&gt; filename)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: teal;"&gt;Stream&lt;/span&gt; stream = &lt;span style="color: teal;"&gt;File&lt;/span&gt;.Open(filename, &lt;span style="color: teal;"&gt;FileMode&lt;/span&gt;.Create))&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;BinaryFormatter&lt;/span&gt; formatter = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;BinaryFormatter&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; formatter.Serialize(stream, &lt;span style="color: blue;"&gt;this&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt; LoadFromFile(&lt;span style="color: blue;"&gt;string&lt;/span&gt; filename)&lt;/p&gt;&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: teal;"&gt;Stream&lt;/span&gt; stream = &lt;span style="color: teal;"&gt;File&lt;/span&gt;.Open(filename, &lt;span style="color: teal;"&gt;FileMode&lt;/span&gt;.Open))&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; {&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: teal;"&gt;BinaryFormatter&lt;/span&gt; formatter = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;BinaryFormatter&lt;/span&gt;();&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; (&lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt;)formatter.Deserialize(stream);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; }&lt;/p&gt;&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here is an example how to use these methods:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: green;"&gt;//create new object&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt; myObject = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"John"&lt;/span&gt;, 30, &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;DateTime&lt;/span&gt;(1967, 1, 1));&lt;/p&gt;&lt;p style="margin: 0px;"&gt;myObject.score = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: blue;"&gt;double&lt;/span&gt;[] { 5.5, 5.6, 6.1 };&lt;/p&gt;&lt;p style="margin: 0px;"&gt;myObject.SaveToFile(&lt;span style="color: maroon;"&gt;"store"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;myObject = &lt;span style="color: blue;"&gt;null&lt;/span&gt;; &lt;span style="color: green;"&gt;//discard object&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: green;"&gt;//load saved object&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;myObject = &lt;span style="color: teal;"&gt;MyExampleClass&lt;/span&gt;.LoadFromFile(&lt;span style="color: maroon;"&gt;"store"&lt;/span&gt;);&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: teal;"&gt;Console&lt;/span&gt;.WriteLine(myObject.name);&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;That is all. It is very simple to use.&lt;br /&gt;&lt;br /&gt;Note: Instead of &lt;code&gt;BinaryFormatter&lt;/code&gt; you can use &lt;code&gt;SoapFormatter&lt;/code&gt;.&lt;br /&gt;The code is the same, only replace &lt;code&gt;BinaryFormatter&lt;/code&gt; by &lt;code&gt;SoapFormatter&lt;/code&gt; and use &lt;code&gt;System.Runtime.Serialization.Formatters.Soap&lt;/code&gt; namespace. For this namesapce you have to add reference to &lt;code&gt;System.Runtime.Serialization.Formatters.Soap.dll&lt;/code&gt; assembly in your project.&lt;br /&gt;&lt;br /&gt;The difference is in the saved file. With &lt;code&gt;SoapFormatter&lt;/code&gt; you get a file that is human readable. For our example, the saved file contains:&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border:1px solid black; padding: 8pt; width: 94%; overflow: auto; background-color: #F0F0F0;"&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;a1:MyExampleClass&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;\"&lt;span style="color: blue;"&gt;ref-1\&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;\"&lt;span style="color: blue;"&gt;ref-3\&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;John&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;name&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;age&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;30&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;age&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;dateOfBirth&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&amp;nbsp; &amp;nbsp; 1967-01-01T00:00:00.0000000+01:00&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;dateOfBirth&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;score&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;href&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;\"&lt;span style="color: blue;"&gt;#ref-4\&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;a1:MyExampleClass&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;SOAP-ENC:Array&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;id&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;\"&lt;span style="color: blue;"&gt;ref-4\&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;SOAP-ENC:arrayType&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;\"&lt;span style="color: blue;"&gt;xsd:double[4]\&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;item&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;5.5&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;item&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;item&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;5.6&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;item&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;item&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;6.1&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;item&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;SOAP-ENC:Array&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Notice how the reference-typed objects are stored.&lt;br /&gt;&lt;br /&gt;Anyone can change the content of this file and the object will reflect these changes after deserialization.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fsimple-serialization-and.html"&gt;&lt;img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fdotnet-enthusiast.blogspot.com%2f2007%2f05%2fsimple-serialization-and.html" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;script&gt;reddit_url='http://dotnet-enthusiast.blogspot.com/2007/05/simple-serialization-and.html'&lt;/script&gt;&lt;br /&gt;&lt;script&gt;reddit_title='Simple Serialization and Deserialization in C#'&lt;/script&gt;&lt;br /&gt;&lt;script src='http://reddit.com/button.js?t=1' type='text/javascript'&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-5719253525358055549?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Kwbu2FyZ8ug3K0d9dOyCAG7qwNk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Kwbu2FyZ8ug3K0d9dOyCAG7qwNk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Kwbu2FyZ8ug3K0d9dOyCAG7qwNk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Kwbu2FyZ8ug3K0d9dOyCAG7qwNk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/-icoHTIBJtk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/5719253525358055549/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=5719253525358055549" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5719253525358055549?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/5719253525358055549?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/-icoHTIBJtk/simple-serialization-and.html" title="Simple Serialization and Deserialization in C#" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/05/simple-serialization-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8MRHczeyp7ImA9WB9TFE0.&quot;"><id>tag:blogger.com,1999:blog-7056688550427768102.post-6159146225887979901</id><published>2007-05-06T10:43:00.000-07:00</published><updated>2007-09-21T12:44:45.983-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-21T12:44:45.983-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ndoc" /><category scheme="http://www.blogger.com/atom/ns#" term="xml documentation" /><title>NDoc for .NET 2.0</title><content type="html">Very popular &lt;a href="http://ndoc.sourceforge.net/"&gt;NDoc Code Documentation Generator for .NET&lt;/a&gt; does not supprot .NET assemblies 2.0. There is a very good unofficial tool for .NET 2.0 by Kevin Downs. You can find more information on this &lt;a href="http://www.kynosarges.de/NDoc.html"&gt;website&lt;/a&gt;. I have already tried it and it works very good.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.kynosarges.de/misc/NDoc2-Alpha3u.zip"&gt;Download NDoc 2.0 Alpha&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7056688550427768102-6159146225887979901?l=dotnet-enthusiast.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/lAMPbBeEjo2VxWeWIYW7XvjBG14/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lAMPbBeEjo2VxWeWIYW7XvjBG14/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/lAMPbBeEjo2VxWeWIYW7XvjBG14/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/lAMPbBeEjo2VxWeWIYW7XvjBG14/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/netEnthusiast/~4/2-BtJWHvtSE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://dotnet-enthusiast.blogspot.com/feeds/6159146225887979901/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=7056688550427768102&amp;postID=6159146225887979901" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/6159146225887979901?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/7056688550427768102/posts/default/6159146225887979901?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/netEnthusiast/~3/2-BtJWHvtSE/ndoc-for-net-20.html" title="NDoc for .NET 2.0" /><author><name>Stanislav Basovník</name><uri>http://www.blogger.com/profile/08247216717135747373</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://dotnet-enthusiast.blogspot.com/2007/05/ndoc-for-net-20.html</feedburner:origLink></entry></feed>

