我可以命名以数字开头的C#名称空间吗? [英] Can i name a C# namespace starting with a number?

查看:283
本文介绍了我可以命名以数字开头的C#名称空间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac上,现在无法自己尝试.

I'm on a Mac and can't try it for myself right now.

例如,它将编译:

namespace 2something.something.else { }

推荐答案

不,你不能.

名称空间名称是一个标识符,标识符的第一个字符的语法(C#4规范的第2.4.2节)是

A namespace name is an identifier and the grammar for the first character of identifiers (§2.4.2 of C# 4 specification) is

identifier-start-character:
    letter-character
    _ (the underscore character U+005F)

这意味着第一个字符必须是下划线或字母(包括非拉丁文字的字母,例如阿拉伯语或中文).

That means that the first character has to be an underscore or a letter (including letters in non-Latin scripts, such as Arabic or Chinese).

这篇关于我可以命名以数字开头的C#名称空间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆