<?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>The Infinite Loop - Beginner&#039;s SEO, Beginner C# &#38; JQuery Tutorials &#187; C#</title>
	<atom:link href="http://theinfiniteloopblog.com/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://theinfiniteloopblog.com</link>
	<description>Problem. Problem Solved. Loop. - The life of a programmer</description>
	<lastBuildDate>Wed, 17 Aug 2011 15:29:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Automatic Get/Set Visual C# 2010</title>
		<link>http://theinfiniteloopblog.com/gen/automatic-getset-visual-c-2010/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=automatic-getset-visual-c-2010</link>
		<comments>http://theinfiniteloopblog.com/gen/automatic-getset-visual-c-2010/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 15:29:45 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://theinfiniteloopblog.com/?p=445</guid>
		<description><![CDATA[One of my favorite features of c#. Automatic getters/setters! Before, one would have to declare a variable. private int _x; And then write get/set methods: public int X{ get{return _x;} set{x=value;} } However, in VISUAL C# 2010 - you can now do the following: public int X{get;set;} Which is the same as the code above! [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>One of my favorite features of c#. Automatic getters/setters!</p>
<p>Before, one would have to declare a variable.</p>
<p><code>private int _x;</code><br />
And then write get/set methods:</p>
<p><code>public int X{<br />
     get{return _x;}<br />
     set{x=value;}<br />
}</code></p>
<p>However, in VISUAL C# 2010 - you can now do the following:<br />
<code>public int X{get;set;}</code>  Which is the same as the code above!</p>
<p>Note: If you want to wrap any validation or anything around the get/set you will still need to write out the full get/set. However, for quick variables that require no extra work - the automatic get/set is a lifesaver! (or timesaver - if you're life is not in danger...whichever you prefer)</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/gen/automatic-getset-visual-c-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursing through a directory/filesystem using C#</title>
		<link>http://theinfiniteloopblog.com/gen/recursing-through-a-directoryfilesystem-using-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=recursing-through-a-directoryfilesystem-using-c</link>
		<comments>http://theinfiniteloopblog.com/gen/recursing-through-a-directoryfilesystem-using-c/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 21:34:37 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=220</guid>
		<description><![CDATA[This will teach you how to recurse through a directory/filesystem using C#.. The problem comes from not knowing how many folders/files exist. One folder can have many folders inside it, those folders can each have many folders inside it. I will show you how to recurse through the filesystem and explain it so that you [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>This will teach you how to <strong>recurse through a directory/filesystem using C#.</strong>.<br />
The problem comes from not knowing how many folders/files exist.<br />
One folder can have many folders inside it, those folders can each have many folders inside it.</p>
<p>I will show you how to recurse through the filesystem and explain it so that you UNDERSTAND it. This isnt for copy-paste.</p>
<p>We will start with a C# console application and pick a path, we'll use C: for this.<br />
First of all, we're going to need the IO namespace. The IO namespace has access to File and Directory methods.</p>
<p>At the top add these lines:</p>
<pre>
using System; //Just so we can use the shortcut Console instead of System.Console
using System.IO; //Gives us access to file, directory objects</pre>
<p>Now, in our "main" method, we are going to write the following:</p>
<pre>
string path="C:/"; //set the root path we want to recurse through.

//check if the directory exists
if(Directory.Exists(path)){
        DirectoryInfo di=new DirectoryInfo(path);
        //based on a path, this object will give you directory information about that directory
        printDirectories(di);
        //this method will actually go through our directories and print out information
}else{
        Console.WriteLine("Directory does not exist. Press Enter to exit");
        Console.ReadLine(); //when you hit return the program will terminate.
}
</pre>
<p><!--adsense--><br />
Now we will write the print directories method. It takes a DirectoryInfo object as a parameter and will use that to recurse through the file system.</p>
<p>//declared as static because were a console app, this can be private in your application if it a utility method.<br />
2 Important methods we're going to be looking at are in the DirectoryInfo object. They are</p>
<p>public FileInfo[] directoryInfoObject.GetFiles() //returns an array of FileInfo objects<br />
public DirectoryInfo[] directoryInfoObject.GetDirectories() //returns an array of DirectoryInfo objects</p>
<pre>static void printDirectories(DirectoryInfo di){
       foreach(FileInfo fi in di.GetFiles()){
              //we are going to run code for each file
              Console.WriteLine(fi.FullName); //this prints out the full file name including the path
       }

      //now that we process this directory for files, we do the same for every subdirectory in this directory
      foreach(DirectoryInfo subDir in di.GetDirectories()){
             //we are going to call the printDirectories method, with the subdirectory as the root.
            //its files will be processed, then its subdirectories will be checked
            //this happens foreach Directory in the current directory
            printDirectories(subDir); //recurse
      }
}</pre>
<p>Thats simple recursion. The most common use of this is for populating a treeview and another use that comes to mind is file searching. Keep an eye out for the next tutorial: Populating a Treeview from a file system!</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/gen/recursing-through-a-directoryfilesystem-using-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating/Retrieving a GUID object from a string C#</title>
		<link>http://theinfiniteloopblog.com/programming/creatingretrieving-a-guid-object-from-a-string-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creatingretrieving-a-guid-object-from-a-string-c</link>
		<comments>http://theinfiniteloopblog.com/programming/creatingretrieving-a-guid-object-from-a-string-c/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 23:35:01 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=216</guid>
		<description><![CDATA[GUIDS are great to use if you ever may need to merge data. The chances of collision (duplicates) are extremely low. To generate a new guid, use this code: Guid g=Guid.NewGuid(); //this generates a GUID object Guid g2=Guid.NewGuid().ToString(); //this generates a GUID string There may be a time where in a stored procedure, you have [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>GUIDS are great to use if you ever may need to merge data.<br />
The chances of collision (duplicates) are extremely low.</p>
<p>To generate a new guid, use this code:<br />
Guid g=Guid.NewGuid(); //this generates a GUID object<br />
Guid g2=Guid.NewGuid().ToString(); //this generates a GUID string<br />
<br/><br />
<!--adsense--><br />
<br/><br />
There may be a time where in a stored procedure, you have a GUID as a parameter.</p>
<p>In C# you may have to pass this paramater to the procedure.<br />
This is actually very simple.</p>
<p>Given a string that you know is a GUID, you can retrieve a guid object like so:<br />
Guid g=new Guid(myStringGUID);</p>
<p>And thats all folks <img src='http://theinfiniteloopblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/programming/creatingretrieving-a-guid-object-from-a-string-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing and Configuring MySql/Connecting with C#</title>
		<link>http://theinfiniteloopblog.com/dbs/mysql/installing-and-configuring-mysqlconnecting-with-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-and-configuring-mysqlconnecting-with-c</link>
		<comments>http://theinfiniteloopblog.com/dbs/mysql/installing-and-configuring-mysqlconnecting-with-c/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 05:26:06 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c sharp]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://scottmoniz.com/programmingBlog/?p=42</guid>
		<description><![CDATA[Recently, I was asked to do some C# development with MySQL as the backend. Having C# with SQL Server 2005 development under my belt setting up a connection to a MySQL Server was pretty easy, however, I will walk you through the setup. Two packages you will need are the MySQL Essentials Installer(this installs the [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>Recently, I was asked to do some C# development with MySQL as the backend.<br />
Having C# with SQL Server 2005 development under my belt setting up a connection to a MySQL Server was pretty easy, however, I will walk you through the setup.</p>
<p>Two packages you will need are the MySQL Essentials Installer(this installs the server)<br />
and the MySQL Connecter/.NET Installer(this installs the bridge between MySQL and .NET)<br />
The third package, the GUI tools, is optional, but it is a lot easier to work with. (Think of it as a Management Studio Express, for those of you who have used SQL 2005)</p>
<p>MySQL Essentials Package: <a title="http://dev.mysql.com/downloads/mysql/5.1.html#downloads" href="http://dev.mysql.com/downloads/mysql/5.1.html#downloads" target="_blank">http://dev.mysql.com/downloads/mysql/5.1.html#downloads<br />
</a>MySqlConnector/NET: <a title="http://www.mysql.com/products/connector/net/" href="http://www.mysql.com/products/connector/net/" target="_blank">http://www.mysql.com/products/connector/net/</a><br />
MySQL Gui Tools: <a title="http://dev.mysql.com/downloads/gui-tools/5.0.html" href="http://dev.mysql.com/downloads/gui-tools/5.0.html" target="_blank">http://dev.mysql.com/downloads/gui-tools/5.0.html</a></p>
<p>Run the Essentials Package first, this package actually contains the server instance.<br />
Follow the prompts, they are pretty much straight forward.<br />
When you receive the prompt about your root password, pick a password.</p>
<p>Next install the MySQL Connector.<br />
Follow the prompts, they are pretty much straight forward as well, and should install pretty quickly.</p>
<p>From here, you can use the command line client located in Start&gt;Program Files&gt;MySql Version&gt;MySql Command Line Client, however, I choose to use the GUI tools instead.<br />
If you have not already, launch the GUI tools installer.</p>
<p>Once this is done, go to Start&gt;Program Files&gt;MySql Version#&gt;MySQL query browser<br />
Click the  ... button next to Stored Connection.<br />
Click New Connection.</p>
<p>Fill out the properties<br />
Connection: Name the connection<br />
Username: root<br />
Password: password used during setup<br />
Hostname: localhost<br />
Port: default is 3306<br />
Schema: specify the default database, you can leave this blank.</p>
<p>Click apply and close.<br />
In the connection screen, from the dropdown, pick the connection we just created.<br />
Type your password.<br />
If given a warning about a default schema, type  test or default in the Default Schema field, this will create<br />
a database named test or default. You can always delete this dummy database afterwards.</p>
<p>To create tables right click your database in the Schemata and click Create New Table.<br />
Most of the GUI is intuitive and should be picked up quite easy.</p>
<p><strong>Connecting to MySQL using C#</strong></p>
<p>Start a C# Application project (I'm using a Console App in my example)<br />
Right click your project and click Add Reference.<br />
Navigate to the Connector DLL.<br />
By default this dll is located at C:/Program Files/MySql/MySql Connector .NET Version#/Binaries/.NET 2.0/MySql.Data.dll</p>
<p>Once this is added add the line:<br />
using MySql.Data.MySqlClient;<br />
using System.Data; //for the ConnectionState enum<br />
to the top of your code.</p>
<p>Add this code to your main/load method:</p>
<p>//sets up the connection string<br />
string connString = "Server = localhost; Database = databaseName; Uid = root; Pwd = pass;";<br />
//creates a new MySqlConnection object<br />
MySqlConnection conn = new MySqlConnection(connString);</p>
<p>try{<br />
//try to open the connection, catch any exceptions<br />
conn.Open();<br />
//if the connection succeeds, print a msg<br />
Console.WriteLine("Connection Succeeded");<br />
}catch(Exception ex){<br />
//print that the connection failed, and the associated Message<br />
Console.WriteLine("Connection Failed: "+ex.Message);<br />
}finally{<br />
//if the connection is currently open, close it<br />
if(conn.State==ConnectionState.Open)<br />
conn.Close();<br />
}</p>
<p><strong>Troubleshooting:</strong></p>
<ul>
<li>If you are having trouble connecting, check your username and password.</li>
<li>Double check the connection string.</li>
<li>If you are sure the above is correct, make sure the MySql server instance is running. You can do this by</li>
<li>going to Start&gt;Run. Type services.msc and hit Ok. Scroll down the list to MySql, it should say started. If it does not, right click and hit Start.</li>
<li>Try to connect with the MySql GUI tools.</li>
</ul>
<p>Just about everything you can do with SQL Server you can do with MySql using the familiarly named classes:<br />
MySqlConnection, MySqlCommand, MySqlDataReader</p>
<p>Hope this gets you started on using MySql and C#.<br />
Any questions or comments, feel free to ask.</p>
]]></content:encoded>
			<wfw:commentRss>http://theinfiniteloopblog.com/dbs/mysql/installing-and-configuring-mysqlconnecting-with-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

