<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tiny Frog Software &#187; C#</title>
	<atom:link href="http://www.tinyfrogsoftware.com/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tinyfrogsoftware.com</link>
	<description></description>
	<lastBuildDate>Wed, 28 Dec 2011 20:12:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Fun with C# and in-memory linq queries</title>
		<link>http://www.tinyfrogsoftware.com/fun-with-c-and-in-memory-linq-queries/</link>
		<comments>http://www.tinyfrogsoftware.com/fun-with-c-and-in-memory-linq-queries/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 16:12:29 +0000</pubDate>
		<dc:creator>Joshua Smyth (Admin)</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.tinyfrogsoftware.com/blog/fun-with-c-and-in-memory-linq-queries/</guid>
		<description><![CDATA[Linq is probably one of my favoriate features of C# and to show you why here is a quick code demonstration. Quite often you want to write some code that has to iterate over the collection; For example: Finding an element in a list of to see if it is present. For a program I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>Linq is probably one of my favoriate features of C# and to show you why here is a quick code demonstration.</p>
<p>Quite often you want to write some code that has to iterate over the collection; For example: Finding an element in a list of to see if it is present.</p>
<p>For a program I&#8217;m working on at my day job, I decided to implement a rule that says each account must have at least one user who has admin rights for the account, and here is some code that checks that condition.</p>
<p>(Note to self: Find good code formatting plug-in for wordpress)</p>
<p><code> <font color="#008000"> bool AtLeastOneAdmin = false;<br />
foreach(User u in Users)<br />
{<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (u.isAdmin)<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AtLeastOneAdmin = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
</font></code><br />
Pretty straightforward, Now lets write the same code using Linq:<br />
<code><br />
<font color="#008000">Bool AtLeastOneAdmin = (from u in users where u.isAdmin == true select u).Count() &gt; 0;</font><br />
</code></p>
<p>That does the exact same thing and only takes up one line of code!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyfrogsoftware.com/fun-with-c-and-in-memory-linq-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

