title: C#: Why did the design team decide against syntax allowing whitespace in identifiers?
body: <p>In Visual Basic you can have the following syntax:</p>
  
  <pre><code>Dim [My variable with spaces]
  [My variable with spaces] = 9000
  </code></pre>
  
  <p>In SQL Server: (I realize this is unrelated to C# but just using as example of syntax)</p>
  
  <pre><code>create table [My Table With Spaces](
  [My Column With Spaces] varchar(30) null)
  </code></pre>
  
  <p>My question is, why was this syntax never incorporated into C#?</p>
  
  <p>I know people might think this is silly, would rarely be used, it's bad practice to have whitespace in identifiers, etc. Well, it must not be that bad of practice if it has support in Visual Basic and SQL Server. 
  In C# it would instantly solve the issue of friendly enums. Most of the solutions now involve using the DescriptionAttribute:</p>
  
  <pre><code>public enum UnitedStates
  {
      [Description("Alabama")]
      Alabama,
      //...
      [Description("New Hampshire")]
      NH,
      //...
      [Description("Wyoming")]
      Wyoming
  }
  public static class Extensions
  {
      public static string GetDescription(this Enum self)
      {
          //tedious, inefficient reflection stuff...
      }
  }
  </code></pre>
  
  <p>Not only does this require a lot more code than it should, it fails with ASP.NET data-binding methods that use the ToString() in data binding. For example:</p>
  
  <pre><code>public class Person
  {
      public string Name { get; set; }
      public UnitedStates FavoriteState { get; set; }
  }
  </code></pre>
  
  <p>and this in ASPX:</p>
  
  <pre><code>&lt;asp:GridView ID="myGridView" runat="server"&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="Name" HeaderText="Name" /&gt;
          &lt;asp:BoundField DataField="FavoriteState" HeaderText="Favorite State" /&gt;&lt;%--NO!--%&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>As you can see, DescriptionAttribute is looking less and less robust a solution. Now consider the following:</p>
  
  <pre><code>public enum UnitedStates
  {
      Alabama,
      //...
      [New Hampshire],
      //...
      Wyoming
  }
  var myFavoriteState = UnitedStates.[New Hampshire];
  string str = myFavoriteState.ToString(); // YES!
  </code></pre>
  
  <p>From what I've seen, assemblies defined in MSIL support fields, properties, variables, etc with whitespace in the names. For example, when creating assembly with System.Reflection.Emit:</p>
  
  <pre><code>AssemblyName assemblyName = new AssemblyName("TestModule");
  AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Save);
  ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("TestModule", "TestModule.dll");
  TypeBuilder typeBuilder = moduleBuilder.DefineType("MyType", TypeAttributes.Public | TypeAttributes.BeforeFieldInit);
  typeBuilder.DefineField("My field with spaces", typeof(int), FieldAttributes.Public);
  EnumBuilder usEnum = moduleBuilder.DefineEnum("UnitedStates", TypeAttributes.Public, typeof(int));
  usEnum.DefineLiteral("Alabama", 0);
  usEnum.DefineLiteral("New Hampshire", 1);
  usEnum.CreateType();
  typeBuilder.CreateType();
  assemblyBuilder.Save("TestModule.dll");
  </code></pre>
  
  <p>This works, creating a working assembly. So it seems to me that adding the support in the syntax would be relatively seamless. Another issue I found is that Visual Studio intellisense does not show the public members containing spaces. </p>
  
  <p>While this may seem like more of a wish-list item than a question, I am just wondering why the designers decided to give this support to Visual Basic but not C#.</p>