C #: Why did the design team decide against syntax by resolving spaces in identifiers?

In Visual Basic, you might have the following syntax:

Dim [My variable with spaces]
[My variable with spaces] = 9000

In SQL Server: (I understand this is not related to C #, but just used as an example of syntax)

create table [My Table With Spaces](
[My Column With Spaces] varchar(30) null)

My question is: why was this syntax never included in C #?

I know that people might think that this is stupid, rarely used, bad practice has spaces in identifiers, etc. Well, it should not be so bad if it has support in Visual Basic and SQL Server. In C #, this instantly solves the problem of friendly enumerations. Most solutions now use DescriptionAttribute:

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...
    }
}

, , ASP.NET, ToString() . :

public class Person
{
    public string Name { get; set; }
    public UnitedStates FavoriteState { get; set; }
}

ASPX:

<asp:GridView ID="myGridView" runat="server">
    <Columns>
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:BoundField DataField="FavoriteState" HeaderText="Favorite State" /><%--NO!--%>
    </Columns>
</asp:GridView>

, DescriptionAttribute . :

public enum UnitedStates
{
    Alabama,
    //...
    [New Hampshire],
    //...
    Wyoming
}
var myFavoriteState = UnitedStates.[New Hampshire];
string str = myFavoriteState.ToString(); // YES!

, , , MSIL, , , .. . , System.Reflection.Emit:

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");

, . , . , , , Visual Studio intellisense , .

, , , Visual Basic, #.

+4

All Articles