Where can I get a list of reserved keywords in C#? [closed]

ε祈祈猫儿з 提交于 2019-12-01 21:23:45

问题


Where can I get a list of reserved keywords in C#?


回答1:


From Microsoft's website:

Microsoft Visual Studio 2008/.NET Framework 3.5

  • abstract
  • as
  • base
  • bool
  • break
  • byte
  • case
  • catch
  • char
  • checked
  • class
  • const
  • continue
  • decimal
  • default
  • delegate
  • do
  • double
  • event
  • explicit
  • extern
  • false
  • finally
  • fixed
  • float
  • for
  • foreach
  • goto
  • if
  • implicit
  • in
  • int
  • interface
  • internal
  • is
  • lock
  • new
  • null
  • object
  • operator
  • out
  • override
  • params
  • private
  • protected
  • public
  • readonly
  • ref
  • return
  • sbyte
  • sealed
  • short
  • sizeof
  • stackalloc
  • struct
  • switch
  • this
  • throw
  • true
  • try
  • typeof
  • uint
  • ulong
  • unchecked
  • unsafe
  • ushort
  • using
  • virtual
  • void
  • volatile
  • while



回答2:


Note that if you need the keywords because you are automatically generating C# code to be compiled, you can use, for example, @new as a variable identifier even though new is a reserved word.

I'm having trouble finding the specific MSDN link explaining that, but csharp-online has this page on it.



来源:https://stackoverflow.com/questions/1319550/where-can-i-get-a-list-of-reserved-keywords-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!