标识符的命名:
标识符可以由任意的大小写字母、数字、下划线(_)和@符号组成,——>但是,
1.不可以——>不可以以数字开头
2.不可以——>不可以以0为关键字
3.不可以——>在命名时不可以出现关键字
4.不可以——>不可以包含空格
与其他的编程不一样的是C#可以以下划线开头
以下是一些例子:
正确: 错误:
username 123username(以数字开头)
username123 class(包含关键字)
user_name 666(以数字命名)
_username Hello World(包含空格)
{关键字:
abstract | as | base | bool | break | byte | case |
catch | char | checked | class | const | continue | decimal |
default | delegate | do | double | else | enum | event |
explicit | extern | false | finally | fixed | float | for |
foreach | goto | if | implicit | in | in (generic modifier) | int |
interface | internal | is | lock | long | namespace | new |
null | object | operator | out | out (generic modifier) | override | params |
private | protected | public | readonly | ref | return | sbyte |
sealed | short | sizeof | stackalloc | static | string | struct |
switch | this | throw | true | try | typeof | uint |
ulong | unchecked | unsafe | ushort | using | virtual | void |
volatile | while |
add | alias | ascending | descending | dynamic | from | get |
global | group | into | join | let | orderby | partial (type) |
partial (method) | remove | select | set |
}