<?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>eXclusiveMinds &#187; Enum</title>
	<atom:link href="http://eXclusiveMinds.com/tag/enum/feed/" rel="self" type="application/rss+xml" />
	<link>http://eXclusiveMinds.com</link>
	<description>eXclusive resource for programmers, developers and designers</description>
	<lastBuildDate>Sat, 13 Mar 2010 23:28:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to convert enum values to string and vice-versa in C#</title>
		<link>http://eXclusiveMinds.com/2009/12/02/how-to-convert-enum-values-to-string-and-vice-versa-in-c/</link>
		<comments>http://eXclusiveMinds.com/2009/12/02/how-to-convert-enum-values-to-string-and-vice-versa-in-c/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 20:15:08 +0000</pubDate>
		<dc:creator>eXclusiveMinds</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Enum]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://eXclusiveMinds.com/?p=123</guid>
		<description><![CDATA[This is simple example about converting Enum to String and vice-versa. We&#8217;ve two simple example showing conversion of enum to string and string to enum.
i. Enum to String
ii. String to Enum

Enum to string
Converting Enum to String using Enum.ToString
method.

Game Game = Game.Football;
string str = Game.ToString&#40;&#41;;  // &#34;Football&#34;

String to Enum
Converting string to enum using static method [...]]]></description>
			<content:encoded><![CDATA[<p>This is simple example about converting Enum to String and vice-versa. We&#8217;ve two simple example showing conversion of enum to string and string to enum.<br />
i. Enum to String<br />
ii. String to Enum<br />
<span id="more-123"></span><br />
<strong>Enum to string</strong></p>
<p>Converting Enum to String using <a href="http://msdn2.microsoft.com/en-us/library/system.enum.tostring.aspx">Enum.ToString</a><br />
method.</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="csharp" style="font-family:Consolas; monospace;">Game Game <span style="color: #008000;">=</span> Game.<span style="color: #0000FF;">Football</span><span style="color: #008000;">;</span>
<span style="color: #FF0000;">string</span> str <span style="color: #008000;">=</span> Game.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>  <span style="color: #008080; font-style: italic;">// &quot;Football&quot;</span></pre></div></td></tr></table></div>

<p><strong>String to Enum</strong></p>
<p>Converting string to enum using static method <a href="http://msdn2.microsoft.com/en-us/library/system.enum.parse.aspx">Enum.Parse</a>.</p>
<p>This method gets enum type as parameter and Optionally we can ignore case too.</p>

<div class="wp_syntax"><table><tr><td><div class="code"><pre class="csharp" style="font-family:Consolas; monospace;"><span style="color: #FF0000;">string</span> str <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Cricket&quot;</span><span style="color: #008000;">;</span>
Game Game <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>Game<span style="color: #000000;">&#41;</span><span style="color: #FF0000;">Enum</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Game<span style="color: #000000;">&#41;</span>, str<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>  <span style="color: #008080; font-style: italic;">// Game.Cricket</span>
Game Game <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>Game<span style="color: #000000;">&#41;</span><span style="color: #FF0000;">Enum</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>Game<span style="color: #000000;">&#41;</span>, str, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// this is case insensitive</span></pre></div></td></tr></table></div>

<img src="http://eXclusiveMinds.Com/?ak_action=api_record_view&id=123&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://eXclusiveMinds.com/2009/12/02/how-to-convert-enum-values-to-string-and-vice-versa-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
