title: How can I get the name of a C# static class property using reflection?
body: <p>I want to make a C# Dictionary in which the key is the string name of a static property in a class and the value is the value of the property.  Given a static property in the class called MyResources.TOKEN_ONE, how can I get the at the <em>name</em> of the property rather than its value?  I only care about the end part of the property name (e.g. "TOKEN_ONE").</p>
  
  <p>I've edited this to mention that I don't want to map <em>all</em> property values in the Dictionary, just a small subset of everything that's in the class. So assume that I want to get the name for a single property.  Given MyResources.TOKEN_ONE, I want to get back "MyResources.TOKEN_ONE" or just "TOKEN_ONE".</p>
  
  <p>Here's some sample code that shows what I'm trying to do.  I need the property name because I'm trying to generate a javascript variable in which I map the property name to the variable name and the property value to the variable value.  For example, I want the C# Dictionary to generate lines like the one below:</p>
  
  <p>var TOKEN_ONE = "One";</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  namespace MyConsoleApp
  {
     class Program
     {
        static void Main(string[] args)
        {
           Dictionary&lt;String, String&gt; kvp = new Dictionary&lt;String, String&gt;();
  
           // How can I use the name of static property in a class as the key for the dictionary?
           // For example, I'd like to do something like the following where 'PropertyNameFromReflection'
           // is a mechanism that would return "MyResources.TOKEN_ONE"
           kvp.Add(MyResources.TOKEN_ONE.PropertyNameFromReflection, MyResources.TOKEN_ONE);
           kvp.Add(MyResources.TOKEN_TWO.PropertyNameFromReflection, MyResources.TOKEN_TWO);
  
           Console.ReadLine();
        }
     }
  
     public static class MyResources
     {
        public static string TOKEN_ONE
        {
           get { return "One"; }
        }
  
        public static string TOKEN_TWO
        {
           get { return "Two"; }
        }
     }
  }
  </code></pre>