Home > Articles > Programming > C#

  • Print
  • + Share This

Copyright

Presenting C#

Copyright © 2000 by Sams Publishing

All rights reserved. No part of this book shall be reproduced, stored in aretrieval system, or transmitted by any means, electronic, mechanical,photocopying, recording, or otherwise, without written permission from thepublisher. No patent liability is assumed with respect to the use of theinformation contained herein. Although every precaution has been taken in thepreparation of this book, the publisher and author assume no responsibility forerrors or omissions. Nor is any liability assumed for damages resulting from theuse of the information contained herein.

International Standard BookNumber: 0-672-32037-1

Library of Congress Catalog Card Number:00-105188

Printed in the United States of America

First Printing:July 2000

02 01 00 4 3 2 1

Trademarks

All terms mentioned in this book that are known to be trademarks or servicemarks have been appropriately capitalized. Sams Publishing cannot attest to theaccuracy of this information. Use of a term in this book should not be regardedas affecting the validity of any trademark or service mark.

Warning and Disclaimer

Every effort has been made to make this book as complete and as accurate aspossible, but no warranty or fitness is implied. The information provided is onan "as is" basis. The author and the publisher shall have neitherliability nor responsibility to any person or entity with respect to any loss ordamages arising from the information contained in this book.

Introduction

Welcome to Presenting C#. This book is your ticket to quickly getting up to speed with the enterprise programming language that ships with the Common Language Runtime (CLR): C# (pronounced C sharp).

The Next Generation Windows Services Runtime is a runtime environment that not only manages the execution of code, but also provides services that make programming easier. Compilers produce managed code to target this managed execution environment. You get cross-language integration, cross-language exception handling, enhanced security, versioning and deployment support, and debugging and profiling services for free.

The premier language for the CLR is C#. Much of the supporting .NET framework is written in C#; therefore, its compiler can be considered the most tested and optimized compiler of those shipping with the CLR. The C# language borrows power from C++, but with modernization and the addition of type safety--making C# the number one choice for enterprise solutions.

Who Should Read This Book?

If you are new to programming, this book is not for you. This book is intended to get programmers off and running with C#, based on knowledge that they already have. Presenting C# is targeted at programmers who already have programming experience in, for example, C or C++, Visual Basic, Java, or another language.

The transition to C# is easiest when you have a background in C++; however, if you are fluent in a different language, this book will bring you up to date, too. The book is more fun if you have a little knowledge of COM programming, but COM programming is in no way mandatory.

How This Book Is Organized

The book is organized into twelve chapters. Here is a quick rundown on what is presented in each chapter:

  • Chapter 1, "Introduction to C#"—You are taken on a tour of C#, and this chapter answers questions about why you should consider learning C#.
  • Chapter 2, "The Underpinnings—The CLR"—You are introduced to how the Common Language Runtime (CLR) provides the infrastructure for your C# code to run.
  • Chapter 3, "Your First C# Application"—You create your very first C# application and (how could it be otherwise?) it is a "Hello World" application.
  • Chapter 4, "C# Types"—You discover the various types that you can use in your C# applications. You explore the differences between value types and reference types, and how boxing and unboxing works.
  • Chapter 5, "Classes"—You tap the real power of C#, which is object-oriented programming with classes. You learn a great deal about constructors, destructors, methods, properties, indexers, and events.
  • Chapter 6, "Control Statements"—You take over the control of flow in your application. You explore the various selection and iteration statements provided by C#.
  • Chapter 7, "Exception Handling"—You acquire the skills to write applications that are good citizens in the world of the CLR, by implementing proper exception handling.
  • Chapter 8, "Writing Components in C#"—You build a component in C# that can be used by clients across languages because you leverage the CLR.
  • Chapter 9, "Configuration and Deployment"—You learn how conditional compilation works in C#, as well as how to automatically generate documentation from your C# source code. Additionally, this chapter introduces the versioning technology of .NET.
  • Chapter 10, "Interoperating with Unmanaged Code"—You discover how you can use unmanaged code from inside C#, and how unmanaged code can interoperate with your C# components.
  • Chapter 11, "Debugging C# Code"—You acquire the skills to use the debugging tools provided in the SDK to pinpoint and fix bugs in your C# applications.
  • Chapter 12, "Security"—You explore the security concepts of the CLR. You learn about code-access security and role-based security.

What You Will Need to Use This Book

From the book's point of view, all you need is the .NET Software Development Kit (SDK). Although all you need at a minimum are the Common Language Runtime (CLR) and the C# compiler, having a machine loaded with the documentation and all the SDK's tools (including its debugger) is definitely a good idea when exploring the capabilities of this exciting new technology.

This book does not require you to have any of the Visual Studio 7 tools installed on your machine. My only recommendation is that you should have a decent programmer's editor that supports line numbering for editing C# source files.

Acknowledgements

What would you expect when you receive an email from an executive editor, mentioning that he wants to talk with you about an exciting book project? I didn't quite expect this book when Chris Webb called me. Chris's offer was way too exciting to turn down—writing a book about a new programming language.

Thanks to both Chris Webb and Brad Jones (the associate publisher) for putting their trust in me and my tight writing schedule. Both of them—as well as the development editor, Kevin Howard—had to put up with my changes to the table of contents as the book progressed. You just can't kill old habits.

Special thanks to Christian Koller for reviewing my chapters and telling me when I once again left out details that non-C++ programmers would need for better understanding. Although I don't know everyone who was involved in this book project at Sams Publishing, I thank them all for bringing it to the shelves--especially within this tight schedule!

Finally, and of course most importantly, I want to thank my family for their continual support throughout all my book projects.

About the Author

Christoph Wille, MCSE, MCSD, CNA, and MCP-IT, works as a network consultant and programmer, and specializes in Windows DNA. He is recognized by Microsoft as a Most Valuable Professional (MVP) for Active Server Pages, and was one of only a handful of developers working with Microsoft on early versions of the C# language.

Christoph has authored or contributed to several books, including Sams Teach Yourself ADO 2.5 in 21 Days, Sams Teach Yourself Active Server Pages in 24 Hours, MCSE Training Guide: SQL Server 7 Administration, and Sams Teach Yourself MCSE TCP/IP in 14 Days.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.