Sams Teach Yourself the C# Language in 21 Days


In just 21 days readers will learn how to use the key features of the C# programming language?not only the commands, but how to create entire programs using them within a few simple chapters. This book is designed to teach C# from the ground up?each lesson is built to supplement the chapter before to provide a fully rounded understanding of the C# language. Sams Teach Yourself the C# Language in 21 Days is the only book on the market that takes C# out of the Microsoft Visual Studio and teaches it as a ...

See more details below
Other sellers (Paperback)
  • All (16) from $1.99   
  • New (6) from $26.99   
  • Used (10) from $1.99   
Sending request ...


In just 21 days readers will learn how to use the key features of the C# programming language¿not only the commands, but how to create entire programs using them within a few simple chapters. This book is designed to teach C# from the ground up¿each lesson is built to supplement the chapter before to provide a fully rounded understanding of the C# language. Sams Teach Yourself the C# Language in 21 Days is the only book on the market that takes C# out of the Microsoft Visual Studio and teaches it as a platform-independent language¿letting readers program for Windows, FreeBSD, and Mac OS X. Additional coverage added from the first edition: more and better Windows Forms information, database access, XML, types, runs, appendix for Visual C++ .NET users, plus much more. This book also includes a CD-ROM full of third-party editor software and sample code, making it an easy-to-use, all-in-one package.

Read More Show Less

Product Details

  • ISBN-13: 9780672325465
  • Publisher: Sams
  • Publication date: 6/1/2003
  • Series: Sams Teach Yourself Series
  • Edition number: 2
  • Pages: 816
  • Product dimensions: 7.42 (w) x 9.12 (h) x 1.75 (d)

Meet the Author

About the Author

Bradley L. Jones ( is the site manager for a number of high-profile developer sites—including,, and—and is an executive editor of Jupitermedia's EarthWeb channel, which is a part of Bradley has been working with C# longer than most developers because he was invited to Microsoft before the official beta release. Bradley's background includes experience developing in C, C++, PowerBuilder, SQL Server, and numerous other tools and technologies. Additionally, he is an internationally best-selling author who wrote the original 21 Days book: Sams Teach Yourself C in 21 Days. On and, you find a number of articles from Bradley on topics ranging from .NET to mobile development to general developer topics.

Read More Show Less

Table of Contents



1. Getting Started with C#.

What Is C#? Preparing to Program. The Program-Development Cycle. Creating Your First C# Program. Types of C# Programs. Creating Your First Window Application. Why C#? A High-Level View of .NET. C# and Object-Oriented Programming (OOP). Summary. Q&A. Workshop.


The First Type & Run.

2. Understanding C# Programs.

Dissecting a C# Application. Basic Parts of a C# Application. Exploring the Structure of a C# Application. Analyzing Listing 2.1. Storing Information with Variables. Using Your Variables. Understanding Your Computer's Memory. Introducing the C# Data Types. Numeric Variable Types. Literals Versus Variables. Creating Constants. A Peek at Reference Types. Summary. Q&A. Workshop.

3. Manipulating Values in Your Programs.

Displaying Basic Information. Manipulating Variable Values with Operators. Understanding Punctuators. Moving Values with the Assignment Operator. Working with Mathematical/Arithmetic Operators. Making Comparisons with Relational Operators. Understanding Logical Bitwise Operators. Understanding the Type Operators. Using the sizeof Operator. Shortcutting with the Conditional Operator. Understanding Operator Precedence.Converting Data Types. Understanding Operator Promotion. Bonus Material: For Those Brave Enough. Summary. Q&A. Workshop.

4. Controlling Your Program's Flow.

Controlling Program Flow. Using Selection Statements. Using Iteration Statements. Reviewing goto. Nesting Flow. Summary. Q&A. Workshop.


The Guess Type & Run. The WinGuess Type & Run.

5. The Core of C# Programming: Classes.

Digging into Object-Oriented Programming. Defining a Class. Declaring Classes. Working with Data Members, a.k.a. Fields. Using Static Variables. Inspecting the Application Class. Creating Properties. A First Look at Namespaces. Summary. Q&A. Workshop.

6. Packaging Functionality: Class Methods and Member Functions.

Getting Started with Methods. Using Methods. Understanding Program Flow with Method. Exploring the Format of a Method. Passing Values to Methods. Types of Class Methods. Summary. Q&A. Workshop.

7. Storing More Complex Stuff: Structures, Enumerators, and Arrays.

Working with Structures. Clarifying with Enumerators. Using Arrays to Store Data. Summary. Q&A. Workshop.


The WR01.cs Program.


8. Advanced Method Access.

Overloading Methods. Using a Variable Number of Parameters. Understanding Scope. Creating Classes with No Objects. Revisiting Namespaces. Summary. Q&A. Workshop.

9. Handling Problems in Your Programs: Exceptions and Errors.

Understanding the Concept of Handling Problems. Exception Handling. Adding Finality with finally. Common Exceptions. Defining Your Own Exception Classes. Throwing Your Own Exceptions. Using checked Versus unchecked Statements. What Is Debugging? Understanding the Types of Errors. Finding Errors. Tracing Code with Code Walkthroughs. Working with Preprocessor Directives. Using Debuggers. Summary. Q&A. Workshop.


10. Reusing Existing Code with Inheritance.

Understanding the Basics of Inheritance. Exploring Polymorphism and Inherited Classes. Working with Virtual Methods. Working with Abstract Classes. Sealing Classes. The Ultimate Base Class: Object. Using the is and as Keywords with Classes-Class Conversions. Working with Arrays of Different Object Types. Summary. Q&A. Workshop.

11. Formatting Formatting and Retrieving Information.

Understanding Console Input and Output. Formatting Information. Working More Closely with Strings. Getting Information from the Console. Summary. Q&A. Workshop.

12. Tapping into OOP: Interfaces.

Interfaces: A First Look. Using Interfaces. Defining Interfaces. Using Multiple Interfaces. Using Explicit Interface Members. Deriving New Interfaces from Existing Ones. Hiding Interface Members. Summary. Q&A. Workshop.

13. Making Your Programs React with Delegates, Events, and Indexers.

Using an Indexer. Exploring Delegates. Working with Events. Summary. Q&A. Workshop.

14. Making Operators Do Your Bidding: Overloading.

Overloading Functions Revisited. Overloading Operators. Summary. Q&A. Workshop.



A Caution on Week 3.

15. Using Existing Routines from the .NET Base Classes.

Classes in the .NET Framework. Working with a Timer. Getting Directory and System Environment Information. Working with Math Routines. Working with Files. Working with Simple Data Files. Summary. Q&A. Workshop.

16. Creating Windows Forms.

Working with Windows and Forms. Creating Windows Forms. Customizing a Form. Adding Controls to a Form. Summary. Q&A. Workshop.

17. Creating Windows Applications.

Working with Radio Buttons. Working with List Boxes. Adding Menus to Your Forms. Displaying Pop-Up Dialog Boxes and Forms. Summary. Q&A. Workshop.


The Tic Tac Toe Code.

18. Working with Data and Databases.

Understanding Key Database Concepts. Introducing ADO.NET. Connecting to and Working with a Database. Adding, Updating, and Deleting Data. Other Database Concepts. Summary. Q&A. Workshop.

19. Creating Remote Procedures: Web Services.

Creating Web Applications. Examining the Concept of a Component. Web Services. Summary. Q&A. Workshop.


The Web Service File. The Proxy File. Using the Service.

20. Creating Web Applications.

Creating Regular Web Applications. Summary. Q&A. Workshop.

21. A Day for Reflection and Attributes.

Reflecting on Reflection. Understanding Attributes. Reflecting on the Future of C#. Summary. Congratulations! Q&A. Workshop.


Apply What You Know. Show What You Know.


Appendix A. C# Keywords.

abstract. as. base. bool. break. byte. case. catch. char. checked. class. const. continue. decimal. default. delegate. do. double. else. enum. event. explicit. extern. false. finally. fixed. float. for. foreach. get. goto. if. implicit. in. int. interface. internal. is. lock. long. namespace. new. null. object. operator. out. override. params. partial. private. protected. public. readonly. ref. return. byte. sealed. set. short. sizeof. stackalloc. static. string. struct. switch. this. throw. true. try. typeof. uint. ulong. unchecked. unsafe. ushort. using. value. virtual. void. where. while. yield.

Appendix B. Command-Line Compiler Flags for Microsoft Visual C# .NET.

Output. Input. Resource. Code Generation. Errors and Warnings. Programming Language. Miscellaneous. Advanced.

Appendix C. Understanding Number Systems.

The Decimal Number System. The Binary System. The Hexadecimal System.

Appendix D. Using SharpDevelop.

Installing SharpDevelop. Running SharpDevelop. Creating Applications from This Book.


Answers (On CD-ROM).

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)