1. Trang chủ
  2. » Công Nghệ Thông Tin

C# Precisely 2004 doc

215 267 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 215
Dung lượng 3,07 MB

Nội dung

[...]... well-formedness requirements must be expressed as additional side conditions on the grammar Team-LRN C# Precisely Team-LRN 2 1 Compiling, Loading and Executing C# Programs Compiling, Loading and Executing C# Programs Running a C# program involves three stages: compilation (which first checks that the C# program is wellformed and then generates intermediate code, also called bytecode), loading (which... Compilation A C# program consists of one or more source files (with filename suffix cs) A source file may contain one or more type declarations: classes, interfaces, struct types, enum types, and delegate types Before a C# program can be executed, it must be compiled and loaded The C# compiler, such as Microsoft’s csc or the Mono project’s mcs, checks that the program conforms to the syntax for C# programs,... parameter or field or array element In this book, fragments of the C# grammar are presented using an informal notation, with non-terminal symbols such as class-declaration in italics, terminal symbols such as class in typewriter font, and metavariables such as C for class names and M for method names A complete and detailed grammar for C# can be found in the official language specification (see section... of the name proper The pseudo-keywords add, alias, get, global, partial, remove, set, value, where and yield are reserved only in certain contexts 3 C# Naming Conventions The following naming conventions are often followed, although not enforced by the C# compiler: • If a name is composed of several words, then each word (except possibly the first one) begins with an upper case letter Examples: currentLayout,... other programming languages, in which class or public may be a perfectly legal name for a field or method; it should not be used in ordinary C# programming Note that for non-keywords such as i, the identifier @i is the same as i class School { const int @class = 2004; const bool @public = true; String @delegate = "J Smith "; public static int @double(int i) { return 2 * @i; } } School school = new School();... see examples 1 and 2 The /main compiler option can be used to specify the entry point: the class whose Main method must be executed after loading an executable Team-LRN Compiling, Loading and Executing C# Programs 3 Example 1 Complete Program in File Example1.cs Almost all programs need the using System directive (section 25.1) but we leave it out in later examples using System; public class Sum { static... There are standard conversions between all the simple types except bool A conversion marked I is an implicit conversion (no cast required) and one marked E is an explicit conversion (cast required) More precisely, an implicit conversion marked I cannot lose precision, whereas one marked IL may lose precision; neither can throw an exception An explicit conversion marked ER rounds the source value and so... pattern, which is a combination of one or more of the following predefined custom number formatting codes: 0 # , % E0 e0 E+0 e+0 E-0 e-0 ; ’string’ "string" See example 26 and the Net Framework class library documentation for details 7.2.2 DateTime Formatting The code part of a format specification for an object of type DateTime may be one of the predefined standard DateTime formatting codes: Code Character... specification for an object of type DateTime may also be a custom DateTime formatting pattern, which is a combination of one or more of the many predefined custom DateTime formatting codes See the Net Framework documentation for details Team-LRN Strings 23 Example 25 Some Standard Number Format Patterns and Their Effect Formatting is culture sensitive This table shows the formatting obtained in the en-US culture . class="bi x0 y0 w0 h0" alt="" C# Precisely Team-LRN Team-LRN Peter Sestoft Henrik I. Hansen C# Precisely The MIT Press Cambridge, Massachusetts London, England Team-LRN c  2004 Massachusetts Institute. conditions on the grammar. Team-LRN C# Precisely Team-LRN 2 Compiling, Loading and Executing C# Programs 1Compiling, Loading and Executing C# Programs Running a C# program involves three stages:. early version of Generic C#. Later, the .Net Framework Alpha Program provided an implementation of all the new C# 2.0 features, and Ecma International provided C# standards documents. Special thanks

Ngày đăng: 05/08/2014, 10:21

TỪ KHÓA LIÊN QUAN