ebook img

C# 7.0 All-in-One For Dummies PDF

827 Pages·2017·9.67 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C# 7.0 All-in-One For Dummies

C# 7.0 All-in-One For Dummies® Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com Copyright © 2018 by John Wiley & Sons, Inc., Hoboken, New Jersey Media and software compilation copyright © 2018 by John Wiley & Sons, Inc. All rights reserved. Published simultaneously in Canada No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies. Wiley publishes in a variety of print and electronic formats and by print-on- demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com. Library of Congress Control Number: 2017958295 ISBN: 978-111-9-42811-4; ISBN 978-111-9-42810-7 (ebk); ISBN ePDF 978-111-9-42812-1 (ebk) C# 7.0 All-in-One For Dummies® To view this book's Cheat Sheet, simply go to www.dummies.com and search for “C# 7.0 All-in-One For Dummies Cheat Sheet” in the Search box. Table of Contents Cover Introduction About This Book Foolish Assumptions Icons Used in This Book Beyond the Book Where to Go from Here Book 1: The Basics of C# Programming Chapter 1: Creating Your First C# Console Application Getting a Handle on Computer Languages, C#, and .NET Creating Your First Console Application Making Your Console App Do Something Reviewing Your Console Application Introducing the Toolbox Trick Chapter 2: Living with Variability — Declaring Value-Type Variables Declaring a Variable What’s an int? Representing Fractions Handling Floating-Point Variables Using the Decimal Type: Is It an Integer or a Float? Examining the bool Type: Is It Logical? Checking Out Character Types What’s a Value Type? Comparing string and char Calculating Leap Years: DateTime Declaring Numeric Constants Changing Types: The Cast Letting the C# Compiler Infer Data Types Chapter 3: Pulling Strings The Union Is Indivisible, and So Are Strings Performing Common Operations on a String Comparing Strings What If I Want to Switch Case? Looping through a String Searching Strings Getting Input from the Command Line Controlling Output Manually Formatting Your Strings Precisely StringBuilder: Manipulating Strings More Efficiently Chapter 4: Smooth Operators Performing Arithmetic Performing Logical Comparisons — Is That Logical? Matching Expression Types at TrackDownAMate.com Chapter 5: Getting into the Program Flow Branching Out with if and switch Here We Go Loop-the-Loop Looping a Specified Number of Times with for Nesting Loops Don’t goto Pieces Chapter 6: Lining Up Your Ducks with Collections The C# Array Processing Arrays by Using foreach Sorting Arrays of Data Using var for Arrays Loosening Up with C# Collections Understanding Collection Syntax Using Lists Using Dictionaries Array and Collection Initializers Using Sets On Not Using Old-Fashioned Collections Chapter 7: Stepping through Collections Iterating through a Directory of Files Iterating foreach Collections: Iterators Accessing Collections the Array Way: Indexers Looping Around the Iterator Block Chapter 8: Buying Generic Writing a New Prescription: Generics Classy Generics: Writing Your Own Revising Generics Chapter 9: Some Exceptional Exceptions Using an Exceptional Error-Reporting Mechanism Throwing Exceptions Yourself Knowing What Exceptions Are For Can I Get an Exceptional Example? Assigning Multiple catch Blocks Planning Your Exception-Handling Strategy Grabbing Your Last Chance to Catch an Exception Throwing Expressions Chapter 10: Creating Lists of Items with Enumerations Seeing Enumerations in the Real World Working with Enumerations Creating Enumerated Flags Defining Enumerated Switches Book 2: Object-Oriented C# Programming Chapter 1: Object-Oriented Programming — What’s It All About? Object-Oriented Concept #1: Abstraction Object-Oriented Concept #2: Classification Why Classify? Object-Oriented Concept #3: Usable Interfaces Object-Oriented Concept #4: Access Control How C# Supports Object-Oriented Concepts Chapter 2: Showing Some Class Defining a Class and an Object Accessing the Members of an Object An Object-Based Program Example Discriminating between Objects Can You Give Me References? Classes That Contain Classes Are the Happiest Classes in the World Generating Static in Class Members Defining const and readonly Data Members Chapter 3: We Have Our Methods Defining and Using a Method A Method Example for Your Files Having Arguments with Methods Returning Values after Christmas Returning Multiple Values Using Tuples Chapter 4: Let Me Say This about this Passing an Object to a Method Defining Methods Accessing the Current Object Using Local Functions Chapter 5: Holding a Class Responsible Restricting Access to Class Members Why You Should Worry about Access Control Defining Class Properties Getting Your Objects Off to a Good Start — Constructors The C#-Provided Constructor Replacing the Default Constructor Using Expression-Bodied Members Chapter 6: Inheritance: Is That All I Get? Class Inheritance Why You Need Inheritance Inheriting from a BankAccount Class (a More Complex Example) IS_A versus HAS_A — I’m So Confused_A When to IS_A and When to HAS_A Other Features That Support Inheritance The object Class Inheritance and the Constructor The Updated BankAccount Class Chapter 7: Poly-what-ism? Overloading an Inherited Method Polymorphism The Class Business Card: ToString() C# During Its Abstract Period Sealing a Class Chapter 8: Interfacing with the Interface Introducing CAN_BE_USED_AS Knowing What an Interface Is Using an Interface Using the C# Predefined Interface Types Looking at a Program That CAN_BE_USED_AS an Example Unifying Class Hierarchies Hiding Behind an Interface Inheriting an Interface Using Interfaces to Manage Change in Object-Oriented Programs Chapter 9: Delegating Those Important Events E.T., Phone Home — The Callback Problem Defining a Delegate Pass Me the Code, Please — Examples A More Real-World Example Shh! Keep It Quiet — Anonymous Methods Stuff Happens — C# Events Chapter 10: Can I Use Your Namespace in the Library? Dividing a Single Program into Multiple Source Files Dividing a Single Program into Multiple Assemblies Putting Your Classes into Class Libraries Going Beyond Public and Private: More Access Keywords Putting Classes into Namespaces Chapter 11: Improving Productivity with Named and Optional Parameters Exploring Optional Parameters Looking at Named Parameters Dealing with Overload Resolution Using Alternative Methods to Return Values Chapter 12: Interacting with Structures Comparing Structures to Classes Creating Structures Using Structures as Records Book 3: Designing for C# Chapter 1: Writing Secure Code Designing Secure Software Building Secure Windows Applications Building Secure Web Forms Applications Using System.Security Chapter 2: Accessing Data Getting to Know System.Data How the Data Classes Fit into the Framework Getting to Your Data Using the System.Data Namespace Chapter 3: Fishing the File Stream

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.