<?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>Head.SmackOnTable(); &#187; Code Sample</title>
	<atom:link href="http://www.unauthorised-access.com/tag/code-sample/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unauthorised-access.com</link>
	<description>Contains Nuts.</description>
	<lastBuildDate>Fri, 02 Jul 2010 17:46:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Output all properties for any object</title>
		<link>http://www.unauthorised-access.com/2009/07/output-all-properties-for-any-object/</link>
		<comments>http://www.unauthorised-access.com/2009/07/output-all-properties-for-any-object/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 08:51:07 +0000</pubDate>
		<dc:creator>Monty</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[c#.net]]></category>
		<category><![CDATA[Code Sample]]></category>

		<guid isPermaLink="false">http://www.unauthorised-access.com/?p=325</guid>
		<description><![CDATA[private void outputValues(object inputObject) { List&#60;PropertyInfo&#62; propertyInfos = new List&#60;PropertyInfo&#62;(inputObject.GetType().GetProperties()); foreach (PropertyInfo info in propertyInfos) { try { object obj = info.GetValue(inputObject, null); if (obj == null) { continue; } Console.WriteLine(&#34;[{0}]:{1}&#34;, info.Name, obj.ToString()); } catch (Exception) { continue; } } } Replace the Console.WriteLine with whatever you want, log4net,  Debug, trace, etc, and it works!]]></description>
			<content:encoded><![CDATA[<pre class="brush: csharp;">

private void outputValues(object inputObject)
{
List&lt;PropertyInfo&gt; propertyInfos = new List&lt;PropertyInfo&gt;(inputObject.GetType().GetProperties());

foreach (PropertyInfo info in propertyInfos)
{
try
{
object obj = info.GetValue(inputObject, null);
if (obj == null)
{
continue;
}
Console.WriteLine(&quot;[{0}]:{1}&quot;, info.Name, obj.ToString());

}
catch (Exception)
{
continue;
}

}

}
</pre>
<p>Replace the Console.WriteLine with whatever you want, log4net,  Debug, trace, etc, and it works!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unauthorised-access.com/2009/07/output-all-properties-for-any-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
