Jump to content

Keywords in C Sharp

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Supertouch (talk | contribs) at 12:03, 25 January 2010 (Corrected embedded link- no point to having link from C# to the letter C). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The keywords of the C# language determine its features. The language has two types of keyword — contextual and reserved. The reserved keywords such as false or byte may only be used as keywords. The contextual keywords such as where or from are only treated as keywords in certain situations.[1]

C# is case-sensitive and its keywords are always written in lower-case.[2]

If an identifier is needed which would be the same as a reserved keyword, it may be prefixed by the @ character to distinguish it. This facilitates reuse of .NET code written in other languages.[3]

Some frequently used keywords

finally out true byte fixed override try case

for private uint char foreach protected ulong checked goto public unchecked class if

float params typeof catch readonly unsafe const implicit ref ushort continue in return using decimal

sbyte virtual default interface sealed volatile delegate internal short void do is sizeof while double

operator throw break

int lock stackalloc

else long static

enum namespace string

event new struct as explicit null switch abstractbase extern object this bool false

References

  1. ^ Herbert Schildt, C# 3.0: The Complete Reference
  2. ^ Matthew MacDonald, Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional
  3. ^ Harvey M. Deitel, Paul J. Deitel, C# for programmers