<?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>家有小虎 &#187; C#</title>
	<atom:link href="http://jiahu.net/tag/c/feed" rel="self" type="application/rss+xml" />
	<link>http://jiahu.net</link>
	<description>我在路上, 你不在身旁. 想你的时候, 温暖依然.</description>
	<lastBuildDate>Sat, 06 Mar 2010 07:33:23 +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>Convert integer to Enum instance</title>
		<link>http://jiahu.net/convert-integer-to-enum-instance.htm</link>
		<comments>http://jiahu.net/convert-integer-to-enum-instance.htm#comments</comments>
		<pubDate>Mon, 27 Oct 2008 04:19:03 +0000</pubDate>
		<dc:creator>o2ho</dc:creator>
				<category><![CDATA[工作]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[代码]]></category>

		<guid isPermaLink="false">http://cngator.net/?p=774</guid>
		<description><![CDATA[public void EnumInstanceFromInt()
{
// The .NET Framework contains an Enum called DayOfWeek.
// Let&#8217;s generate some Enum instances from int values.
// Usually you wouldn&#8217;t cast an instance of an existing Enum to an int
// in order to create an Enum instance.  :-)  You would have the actual
// integer value, perhaps a value from a database [...]]]></description>
			<content:encoded><![CDATA[<p>public void EnumInstanceFromInt()<br />
{<br />
// The .NET Framework contains an Enum called DayOfWeek.<br />
// Let&#8217;s generate some Enum instances from int values.</p>
<p>// Usually you wouldn&#8217;t cast an instance of an existing Enum to an int<br />
// in order to create an Enum instance.  :-)  You would have the actual<br />
// integer value, perhaps a value from a database where the int value of<br />
// the enum was stored.</p>
<p>DayOfWeek wednesday =<br />
(DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Wednesday);<br />
DayOfWeek sunday =<br />
(DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Sunday);<br />
DayOfWeek tgif =<br />
(DayOfWeek)Enum.ToObject(typeof(DayOfWeek), (int)DayOfWeek.Friday);</p>
<p>lblOutput.Text = wednesday.ToString()<br />
+ &#8220;.  Int value = &#8221; + ((int)wednesday).ToString() + &#8220;\n&#8221;;<br />
lblOutput.Text += sunday.ToString()<br />
+ &#8220;.  Int value = &#8221; + ((int)sunday).ToString() + &#8220;\n&#8221;;<br />
lblOutput.Text += tgif.ToString()<br />
+ &#8220;.  Int value = &#8221; + ((int)tgif).ToString() + &#8220;\n&#8221;;<br />
}</p>
<p>Result:</p>
<p>Wednesday. Int value = 3<br />
Sunday. Int value = 0<br />
Friday. Int value = 5</p>
<p>Link: <a href="http://www.cambiaresearch.com/c4/52a7e5fe-c7fc-49ab-b21d-37e6194687f3/Convert-Integer-To-Enum-Instance-in-csharp.aspx" target="_blank">http://www.cambiaresearch.com/c4/52a7e5fe-c7fc-49ab-b21d-37e6194687f3/Convert-Integer-To-Enum-Instance-in-csharp.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jiahu.net/convert-integer-to-enum-instance.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
