Anda di halaman 1dari 3

C# Keywords

http://msdn.microsoft.com/en-us/library/x53a06bb

C# Keywords
Visual Studio 2010 33 out of 51 rated this helpful - Rate this topic Keywords are predefined, reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include @ as a prefix. For example, @if is a valid identifier but if is not because if is a keyword. The first table in this topic lists keywords that are reserved identifiers in any part of a C# program. The second table in this topic lists the contextual keywords in C#. Contextual keywords have special meaning only in a limited program context and can be used as identifiers outside that context. Generally, as new keywords are added to the C# language, they are added as contextual keywords in order to avoid breaking programs written in earlier versions.

abstract break char continue do event finally foreach in internal namespace operator params readonly sealed static this typeof

as byte checked decimal double explicit fixed goto in (generic modifier) is new out private ref short string throw uint

base case class default else extern float if int lock null out (generic modifier) protected return sizeof struct true ulong

bool catch const delegate enum false for implicit interface long object override public sbyte stackalloc switch try unchecked

1 of 3

5/25/2012 11:50 AM

C# Keywords

http://msdn.microsoft.com/en-us/library/x53a06bb

unsafe void

ushort volatile

using while

virtual

Contextual Keywords
A contextual keyword is used to provide a specific meaning in the code, but it is not a reserved word in C#. Some contextual keywords, such as partial and where, have special meanings in two or more contexts.

add descending get into orderby remove value where (query clause)

alias dynamic global join partial (type) select var yield

ascending from group let partial (method) set where (generic type constraint)

See Also
Concepts C# Programming Guide Other Resources C# Reference

Did you find this helpful?

Yes

No

Community Content
More info on "in"

2 of 3

5/25/2012 11:50 AM

C# Keywords in actually has two uses:

http://msdn.microsoft.com/en-us/library/x53a06bb

1. In a "foreach, in" statement - http://msdn.microsoft.com/en-us/library/ttw7t8t6.aspx 2. As a "generic modifier" - http://msdn.microsoft.com/en-us/library/dd469484.aspx Edit by SJ at MSFT: That's why there are two entries for "in" in the table. Or am I missing your point? 2/6/2012 SJ at MSFT 2/6/2012 DanThMan

The infamous "undocumented keywords"


No doubt someone will ask about the infamous __arglist, __makeref, __reftype, and __refvalue keywords. They are not supported (they are designed (a) for use within the .NET Framework itself and (b) for interoperability with C++/CLI), and that is why they are not listed on this page. See http://www.eggheadcafe.com/articles/20030114.asp for information about these keywords.

1/6/2012 Nevin Janzen

6/30/2010 AtLight

Reply
Yes, but what use are these to the C# programmer day to day? If they are only for compliance with C++/CLI then why should they be listed on this page? Plus, these are not essential to the average C# programmer and beginners will find this confusing.

1/6/2012 Nevin Janzen

2012 Microsoft. All rights reserved.

3 of 3

5/25/2012 11:50 AM

Anda mungkin juga menyukai