文档介绍: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 of Technology
All rights reserved. No part of this book may be reproduced in any form by any electronic or mechanical
means (including photocopying, recording, or information storage and retrieval) without permission in
writing from the publisher.
This book was set in Times by the authors using LATEX.
Printed and bound in the United States of America.
Library of Congress Cataloging-in-Publication Data
Sestoft, Peter.
C# precisely / Peter Sestoft and Henrik I. Hansen.
p. cm.
Includes bibliographic references and index.
ISBN 0-262-69317-8 (pbk.: alk. paper)
1. C# (Computer program language) I. Hansen, Henrik I. II. Title.
2004
3—dc22
2004048288
**********
Team-LRN
Contents
Preface ix
Notational Conventions x
1Compiling, Loading and Executing C# Programs 2
Source Files pilation . . . ............................ 2
Execution . . . . . . . ................................... 2
2Names and Reserved Names 4
3C#Naming Conventions 4
4Comments and Program Layout 4
5Data and Types 6
Value Types and Simple Types . . . ............................ 6
Reference Types ...................................... 8
Conversion . ........................................ 10
6Variables, Parameters, Fields, and Scope 14
Scope of Variables, Parameters and Members (Including Fields) . . . . . . . . . . . . . 14
Default Values and Definite Assignment . . . ....................... 14
7Strings 16
String Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
String Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8String Builders 24
9Arrays 26
One-dimensional Arrays . . . . . . . . .......................... 26
Multi-dimen