<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>XNA Framework</title><link>http://forums.xna.com/forums/56.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/238427.aspx</link><pubDate>Wed, 14 Oct 2009 20:18:06 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:238427</guid><dc:creator>UberGeekGames</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/238427.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=238427</wfw:commentRss><description>I haven&amp;#39;t touched LINQ so using that bit of code as a replacement for Enum.GetValues was more difficult than I expected, so here&amp;#39;s a method that actually gets the enum&amp;#39;s names and puts them into a string array for you:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="border:1px solid #7f9db9;overflow:auto;background-color:white;font-family:courier new;font-size:11px;"&gt;
&lt;table cellspacing="0" cellpadding="0" style="border-width:0px;border-bottom:0px solid #eeeeee;margin:2px 0px;width:99%;border-collapse:collapse;background-color:#ffffff;"&gt;
    
    
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size:11px;"&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;static&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&lt;span style="font-size:11px;"&gt;[]&amp;nbsp;GetEnumNames&amp;lt;T&amp;gt;()&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;{&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IEnumerable&amp;lt;T&amp;gt;&amp;nbsp;tx&amp;nbsp;=&amp;nbsp;(from&amp;nbsp;x&amp;nbsp;&lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;&lt;span style="font-size:11px;"&gt;(T).GetFields(BindingFlags.Static&amp;nbsp;|&amp;nbsp;BindingFlags.Public)&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select&amp;nbsp;(T)x.GetValue(&lt;span style="color:blue;"&gt;null&lt;/span&gt;&lt;span style="font-size:11px;"&gt;));&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;T&amp;gt;&amp;nbsp;rx&amp;nbsp;=&amp;nbsp;tx.ToList();&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;gt;&amp;nbsp;s&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;new&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;List&amp;lt;&lt;/span&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;gt;();&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color:blue;"&gt;foreach&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;(T&amp;nbsp;t&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;rx)&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; s.Add(t.ToString());&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;s.ToArray();&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;}&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
    
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
It&amp;#39;s probably not that efficient but I was quickly hacking it together and figured someone else might benefit.&lt;br /&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/157478.aspx</link><pubDate>Wed, 01 Apr 2009 15:44:24 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:157478</guid><dc:creator>Nick Gravelyn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/157478.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=157478</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;SwiftFalcn:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Actually as far as I understand it your linq query syntax just gets rewritten to his extension method by the compiler. but whatever all the same.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;It does, but LINQ is the query syntax so if you just use the extension methods it&amp;#39;s not technically LINQ. That&amp;#39;s all I was pointing out.&lt;br /&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/157356.aspx</link><pubDate>Wed, 01 Apr 2009 08:38:05 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:157356</guid><dc:creator>SwiftFalcn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/157356.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=157356</wfw:commentRss><description>Actually as far as I understand it your linq query syntax just gets rewritten to his extension method by the compiler. but whatever all the same.&lt;br /&gt;
&lt;br /&gt;
Good to know about GetValues. The compact framework seems to be restrictive in the most unexpected ways.&lt;br /&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/156995.aspx</link><pubDate>Tue, 31 Mar 2009 20:18:24 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:156995</guid><dc:creator>Nick Gravelyn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/156995.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=156995</wfw:commentRss><description>That&amp;#39;s not quite LINQ since you&amp;#39;re just using the Select extension method. If you want LINQ it&amp;#39;d be like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="border:1px solid #7f9db9;overflow:auto;background-color:white;font-family:courier new;font-size:11px;"&gt;
&lt;table cellspacing="0" cellpadding="0" style="border-width:0px;border-bottom:0px solid #eeeeee;margin:2px 0px;width:99%;border-collapse:collapse;background-color:#ffffff;"&gt;
    
    
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size:11px;"&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;static&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;IEnumerable&amp;lt;T&amp;gt;&amp;nbsp;GetValues&amp;lt;T&amp;gt;()&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;{&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:blue;"&gt;return&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;(from&amp;nbsp;x&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;in&lt;/span&gt;&lt;span style="font-size:11px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;&lt;span style="font-size:11px;"&gt;(T).GetFields(BindingFlags.Static&amp;nbsp;|&amp;nbsp;BindingFlags.Public)&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select&amp;nbsp;(T)x.GetValue(&lt;span style="color:blue;"&gt;null&lt;/span&gt;&lt;span style="font-size:11px;"&gt;));&amp;nbsp;&lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;}&amp;nbsp;&lt;/td&gt;
        &lt;/tr&gt;
    
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
using that awesome query syntax. :)&lt;br /&gt;
&lt;br /&gt;
And yeah, I could have put it on one line, but I like breaking up each part of my LINQ queries.&lt;br /&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/156987.aspx</link><pubDate>Tue, 31 Mar 2009 20:07:35 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:156987</guid><dc:creator>Zaknafein</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/156987.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=156987</wfw:commentRss><description>Thread resurrection go!&lt;div&gt;Here&amp;#39;s a LINQ version of that method, because it&amp;#39;s fun and takes up a single line.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;div style="overflow-x:auto;overflow-y:auto;background-color:white;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;font-family:&amp;#39;courier new&amp;#39;;font-size:11px;"&gt;&lt;table cellpadding="0" cellspacing="0" style="width:99%;margin-top:2px;margin-right:0px;margin-bottom:2px;margin-left:0px;border-collapse:collapse;border-bottom-style:solid;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;"&gt;                &lt;tr&gt;            &lt;td&gt;&lt;span style="font-size:11px;"&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;span style="color:blue;"&gt;static&lt;/span&gt;&lt;span style="font-size:11px;"&gt; IEnumerable&amp;lt;T&amp;gt; GetValues&amp;lt;T&amp;gt;() &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;{ &lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;    &lt;span style="color:blue;"&gt;return&lt;/span&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;&lt;span style="font-size:11px;"&gt;(T).GetFields(BindingFlags.Static | BindingFlags.Public).Select(x =&amp;gt; (T)x.GetValue(&lt;/span&gt;&lt;span style="color:blue;"&gt;null&lt;/span&gt;&lt;span style="font-size:11px;"&gt;)); &lt;/span&gt;&lt;/td&gt;        &lt;/tr&gt;        &lt;tr&gt;            &lt;td&gt;} &lt;/td&gt;        &lt;/tr&gt;    &lt;/table&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And I would as well prefer a reference implementation of the method in the Xbox assemblies... I&amp;#39;ll make a Connect entry.&lt;/div&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/107133.aspx</link><pubDate>Fri, 14 Nov 2008 18:54:21 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:107133</guid><dc:creator>Matthew Doucette</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/107133.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=107133</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com//Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;RocketCanGames:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;
&lt;pre&gt;&lt;span style="font-family:courier new;"&gt;        FieldInfo[ fields = currentEnum.GetFields(BindingFlags.Static | BindingFlags.Public);&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br /&gt;
&lt;br /&gt;
Just a note to anyone else coming into this thread, that if you do not specify &amp;quot;BindingFlags.Static | BindingFlags.Public&amp;quot;, then .GetFields() will return an extra field.  For me, the extra field is: [0] = {Int32 value__}</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/107050.aspx</link><pubDate>Fri, 14 Nov 2008 16:54:03 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:107050</guid><dc:creator>Matthew Doucette</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/107050.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=107050</wfw:commentRss><description>I solved it (my previous post) with type casting (which removes range checking):&lt;br /&gt;
&lt;br /&gt;
&lt;div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white;"&gt;
&lt;table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px;" cellspacing="0" cellpadding="0"&gt;
    
    
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size:11px;"&gt;enemyType tempEnemyType = (enemyType)2;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="font-size:11px;"&gt; tempStr = ((enemyType)2).ToString(); &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
    
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
Is there a better solution?</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/107035.aspx</link><pubDate>Fri, 14 Nov 2008 16:04:57 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:107035</guid><dc:creator>Matthew Doucette</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/107035.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=107035</wfw:commentRss><description>&lt;p&gt;I have also run into need for .GetValues().  I always seem to want more power with my enums than I am allowed to have.&lt;/p&gt;
&lt;p&gt;In my enemy type enum, if I use an index from 0..numEnemyTypes-1, can I used this index to access the type and its string name?&lt;/p&gt;
&lt;p&gt;Basically, I want to do this:&lt;/p&gt;
&lt;div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white;"&gt;
&lt;table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px;" cellspacing="0" cellpadding="0"&gt;
    
    
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size:11px;"&gt;enemyType tempEnemyType = enemyType[2]  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt;&lt;span style="font-size:11px;"&gt; tempStr = enemyType[2].ToString() &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
    
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;Where enemyType is an enum of enemy types:&lt;/p&gt;
&lt;div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;border-bottom:#7f9db9 1px solid;font-family:courier new;background-color:white;"&gt;
&lt;table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px;" cellspacing="0" cellpadding="0"&gt;
    
    
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size:11px;"&gt; &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;&lt;span style="color:blue;"&gt;enum&lt;/span&gt;&lt;span style="font-size:11px;"&gt; enemyType  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;{  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;redEnemy,  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;greenEnemy,  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color:#f7f7f7;"&gt;...  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;} &lt;/td&gt;
        &lt;/tr&gt;
    
&lt;/table&gt;
&lt;/div&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/73905.aspx</link><pubDate>Fri, 11 Jul 2008 01:23:19 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:73905</guid><dc:creator>RocketCanGames</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/73905.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=73905</wfw:commentRss><description>&lt;pre&gt;&lt;p&gt;A small update to the function. By making it a generic function, I&amp;#39;m able to return the exact type in a List. Also, instead of throwing&lt;/p&gt;&lt;p&gt;an exception, I just return an empty List.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&amp;nbsp;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static List&amp;lt;T&amp;gt; GetValues&amp;lt;T&amp;gt;()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type currentEnum = typeof(T);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;T&amp;gt; resultSet = new List&amp;lt;T&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (currentEnum.IsEnum)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[ fields = currentEnum.GetFields(BindingFlags.Static | BindingFlags.Public);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (FieldInfo field in fields)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultSet.Add((T)field.GetValue(null));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return resultSet;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/pre&gt;
&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;br /&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/8111.aspx</link><pubDate>Thu, 03 May 2007 22:42:42 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:8111</guid><dc:creator>Nick Gravelyn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/8111.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=8111</wfw:commentRss><description>Thanks. Works great on PC and compiles for 360 so I'm going to guess that it works. Thanks a lot.&lt;br&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/8110.aspx</link><pubDate>Thu, 03 May 2007 22:40:10 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:8110</guid><dc:creator>justastro</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/8110.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=8110</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Nick Gravelyn:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;justastro:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;
&lt;P&gt;I wrote a function for this and it works fine on both&amp;nbsp;Windows and XB360&amp;nbsp;so far.&lt;/P&gt;
&lt;P&gt;(Why the code snippet function in the forum is not work?!)&lt;/P&gt;
&lt;P&gt;public static Enum[] GetEnumValues(Type enumType)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; if (enumType.BaseType == typeof(Enum))&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[] info = enumType.GetFields(BindingFlags.Static | BindingFlags.Public);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum[] values = new Enum[info.Length];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i=0; i&amp;lt;values.Length; ++i)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values[i] = (Enum)info[i].GetValue(null);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return values;&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;&amp;nbsp; else&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new Exception("Given type is not an Enum type");&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;BTW, this function is so useful and I wonder why it is not supported in the .NET CF?&lt;/P&gt;
&lt;P&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;BR&gt;&lt;BR&gt;It looks promising, but when I compile I get errors about FieldInfo and BindingFlags. Where are those defined?&lt;BR&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/P&gt;
&lt;P&gt;The code needs reflection&lt;/P&gt;
&lt;P&gt;using System.Reflection;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/8108.aspx</link><pubDate>Thu, 03 May 2007 22:33:14 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:8108</guid><dc:creator>Nick Gravelyn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/8108.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=8108</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;justastro:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;I wrote a function for this and it works fine on both&amp;nbsp;Windows and XB360&amp;nbsp;so far.&lt;/p&gt;
&lt;p&gt;(Why the code snippet function in the forum is not work?!)&lt;/p&gt;
&lt;p&gt;public static Enum[] GetEnumValues(Type enumType)&lt;br&gt;{&lt;br&gt;&amp;nbsp; if (enumType.BaseType == typeof(Enum))&lt;br&gt;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[] info = enumType.GetFields(BindingFlags.Static | BindingFlags.Public);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum[] values = new Enum[info.Length];&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i=0; i&amp;lt;values.Length; ++i)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values[i] = (Enum)info[i].GetValue(null);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return values;&lt;br&gt;&amp;nbsp; }&lt;br&gt;&amp;nbsp; else&lt;br&gt;&amp;nbsp; {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new Exception("Given type is not an Enum type");&lt;br&gt;&amp;nbsp; }&lt;br&gt;}&lt;/p&gt;
&lt;p&gt;BTW, this function is so useful and I wonder why it is not supported in the .NET CF?&lt;/p&gt;
&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;&lt;br&gt;It looks promising, but when I compile I get errors about FieldInfo and BindingFlags. Where are those defined?&lt;br&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/8107.aspx</link><pubDate>Thu, 03 May 2007 22:27:38 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:8107</guid><dc:creator>justastro</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/8107.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=8107</wfw:commentRss><description>&lt;P&gt;I wrote a function for this and it works fine on both&amp;nbsp;Windows and XB360&amp;nbsp;so far.&lt;/P&gt;
&lt;P&gt;(Why the code snippet function in the forum is not work?!)&lt;/P&gt;
&lt;P&gt;==&lt;/P&gt;
&lt;P&gt;using System.Reflection;&lt;/P&gt;
&lt;P&gt;public static Enum[] GetEnumValues(Type enumType)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp; if (enumType.BaseType == typeof(Enum))&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldInfo[] info = enumType.GetFields(BindingFlags.Static | BindingFlags.Public);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enum[] values = new Enum[info.Length];&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int i=0; i&amp;lt;values.Length; ++i)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; values[i] = (Enum)info[i].GetValue(null);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return values;&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;&amp;nbsp; else&lt;BR&gt;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new Exception("Given type is not an Enum type");&lt;BR&gt;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;==&lt;/P&gt;
&lt;P&gt;BTW, this function is so useful and I wonder why it is not supported in the .NET CF?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/8106.aspx</link><pubDate>Thu, 03 May 2007 22:01:43 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:8106</guid><dc:creator>Nick Gravelyn</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/8106.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=8106</wfw:commentRss><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="http://forums.xna.com/Themes/default/images/icon-quote.gif"&gt; &lt;strong&gt;Shawn Hargreaves:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;If this was me, though, I'd just pass in the maximum value as a parameter when constructing my menu.&lt;br&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;&lt;br&gt;How would that work? I need to get all the values for the Enum.&lt;br&gt;&lt;br&gt;&lt;br&gt;Edit:&lt;br&gt;I decided to try my above solution by compiling it for Windows, and it wouldn't compile for Windows. It compiled at least for 360, but when I try compiling it for Windows I get this error:&lt;br&gt;&lt;br&gt;The type or namespace name 'type' could not be found (are you missing a using directive or an assembly reference?)&lt;br&gt;&lt;br&gt;</description></item><item><title>Re: System.Enum Doesn't Have GetValues On Xbox 360?</title><link>http://forums.xna.com/forums/thread/8072.aspx</link><pubDate>Thu, 03 May 2007 15:10:21 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:8072</guid><dc:creator>Shawn Hargreaves</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/8072.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=8072</wfw:commentRss><description>I don't think just casting an integer to an enum will work - that will actually succeed even if the value isn't in the enum. You could probably hack together some kind of check doing a ToString on the resulting enum to see if that gives back anything sensible.&lt;br&gt;&lt;br&gt;If this was me, though, I'd just pass in the maximum value as a parameter when constructing my menu.&lt;br&gt;</description></item></channel></rss>