SlideServe
Menu
Préférences
© SlideServe · v2026

Symbols

deborah-house avatar
9 diapositives · 268 Views · Nov 10, 2014

Symbols. Identifiers. Syntax Identifier = (letter | '_' | '@') {letter | digit | '_'}. Unicode! Case-sensitive "@" can be used to treat keywords as identifiers - if ... keyword - @if ... identifier if May contain Unicode escape sequences (e.g. \u03c0 for p) Examples someName

Symbols - slide 1
01 / 9Symbols
1 / 17

Télécharger la présentation

Symbols
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Symbols

  2. Identifiers • Syntax • Identifier = (letter | '_' | '@') {letter | digit | '_'}. • Unicode! • Case-sensitive • "@" can be used to treat keywords as identifiers • - if ... keyword • - @if ... identifier if • May contain Unicode escape sequences (e.g. \u03c0 for p) • Examples • someName • sum_of3 • _10percent • @while the identifier while • p the identifier p • \u03c0 the identifier p • b\u0061ck the identifier back

  3. Keywords abstract as base bool breakbyte case catch char checkedclass const continue decimal defaultdelegate do double else enumevent explicit extern false finallyfixed float for foreach gotoif implicit in int interfaceinternal is lock long namespacenew null object operator outoverride params private protected publicreadonly ref return sbyte sealedshort sizeof stackalloc static stringstruct switch this throw truetry typeof uint ulong uncheckedunsafe ushort using virtual voidvolatile while 77 keywords in C# in contrast to 47 keywords in Java

  4. Naming Conventions Casing • Words are capitalized (e.g. ShowDialog) • First letter in upper case, except for private or local variables, constants and fields constants upper case SIZE, MAX_VALUE local variables lower case i, top, sum private fields lower case data, lastElement public fields upper case Width, BufferLength properties upper case Length, FullName enumeration upper case Red, Blue constants methods upper case Add, IndexOf types upper case StringBuilder (predefined types in lower case: int, string) namespaces upper case System, Collections • First word • Names of void methods should start with a verb (e.g. GetHashCode) • Other names should start with a noun (e.g. size, IndexOf, Collections) • Enumeration constants or bool members may start with an adjective (Red, Empty)

  5. Integer Numbers Syntax DecConstant = digit {digit} {IntSuffix}. HexConstant = "0x" hexDigit {hexDigit} {IntSuffix}. IntSuffix = 'u' | 'U' | 'l' | 'L'. Type without suffix: smallest type from int, uint, long, ulong suffix u, U: smallest type from uint, ulong suffix l, L: smallest type from long, ulong Examples 17 int 9876543210 long 17L long 17u uint 0x3f int 0x10000 long 0x3fL long

  6. Floating-point Numbers Syntax (simplified) RealConstant = [Digits] ["." [Digits]] [Exp] [RealSuffix]. must have at least 1 digit and either ".", Exp or RealSuffix Digits = digit {digit}. Exp = ("e" | "E") ["+" | "-"] Digits. RealSuffix = "f" | "F" | "d" | "D" | "m" | "M". Type without suffix: double suffix f, F: float suffix d, D: double suffix m, M: decimal Examples 3.14 double 1E-2 double .1 double 10f float

  7. Character Constants and Strings Syntax CharConstant = ' char '. StringConstant = " {char} ". char can be Any character except closing quote, end-of-line or \ Escape sequences \' ' \" " \\ \ \0 0x0000 \a 0x0007 (alert) \b 0x0008 (backspace) \f 0x000c (form feed) \n 0x000a (new line) \r 0x000d (carriage return) \t 0x0009 (horizontal tab) \v 0x000b (vertical tab) Unicode- or hexadecimal escape sequences \u0061 a \x0061 a

  8. Character Constants and Strings (cont.) Examples for escape sequences in strings "file \"C:\\sample.txt\"" file "C:\sample.txt" "file \x0022C:\u005csample.txt\x0022" • If the string is preceded by a @ • the \ is not interpreted as a escape character • any " must be doubled • the string may span several lines • Example • @"file file • ""C:\sample.txt""" "C:\sample.txt"

  9. Comments Single-line comments // a comment Delimited comments /* a comment */ must not be nested Documentation comments /// a documentation comment