Learn C# in 7 days

Book description

Learn C# in 7 days with practical examples, build a foundation for C# programming, and boost your skills to an advanced level

About This Book

  • Learn the basics of C# in 7 days
  • Works as a reference guide describing the major features of C#
  • Build easy and simple code through real-world example scenarios

Who This Book Is For

The book is for aspiring developers and absolute novices who want to get started with the world of programming. You do not need any knowledge of C# for this book.

What You Will Learn

  • Understand and set up the .NET environment
  • Code in C# using the Visual Studio 2017 RC (preferable community edition) IDE
  • Define variables, syntax, control flows, statements, and arrays etc through examples
  • Understand the concepts of Object-Oriented Programming using C#
  • Get acquainted with attributes, collection, generics, and LINQ
  • Get your hands on class members such as Modifiers, Methods, Properties, Indexers, File I/O, Exception Handling, and Regex
  • Build a real-world application using C# 7

In Detail

This book takes a unique approach to teach C# to absolute beginners. You’ll learn the basics of the language in seven days. It takes a practical approach to explain the important concepts that build the foundation of the C# programming language.

The book begins by teaching you the basic fundamentals using real-world practical examples and gets you acquainted with C# programming. We cover some important features and nuances of the language in a hands-on way, helping you grasp the concepts in a fluid manner.

Later, you’ll explore the concepts of Object-Oriented Programming (OOP) through a real-world example. Then we dive into advanced-level concepts such as generics and collections, and you’ll get acquainted with objects and LINQ. Towards the end, you’ll build an application that covers all the concepts explained in the book.

By the end of this book, you will have next-level skills and a good knowledge of the fundamentals of C#.

Style and approach

Fast paced guide to get you up-to-speed with the language. Every chapter is followed by an exercise that focuses on building something with the language. The codes of the exercises can be found on the Packt website

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Errata
      3. Piracy
      4. Questions
  2. Day 01 - Overview of the .NET Framework
    1. What is programming?
    2. What is .NET?
    3. What is .NET Core?
      1. .NET Core features
      2. What makes .NET Core?
      3. What is .NET Standard?
      4. Available IDEs and editors for C#
      5. Setting up the environment
    4. Hands - on exercises
    5. Revisiting Day 01
  3. Day 02 - Getting Started with C#
    1. Introduction to C#
      1. History of the C# language
    2. Understanding a typical C# program
      1. 1 (System)
      2. 3 (Day02)
      3. 2 (Program)
      4. 4 (Main)
      5. 5 (Day02)
      6. 6 (Day02)
      7. 7 (Dependencies)
      8. 8 (Program.cs)
      9. Deep-dive into application using Visual Studio
      10. Discussing code
        1. Color
        2. Beep
    3. An overview of C# reserved keywords, types, and operators
      1. Identifiers
      2. Contextual
      3. Types
        1. Value type
          1. Data types
        2. Reference type
        3. Pointer type
        4. Null type
      4. Operators
        1. Discussing operator precedence in C#
        2. Operator overloading
    4. An overview of type conversion
      1. Implicit conversion
      2. Explicit conversion
    5. Understanding statements
      1. Declarative statement
      2. Expression statement
      3. Selection statement
        1. The if statement
          1. The if..else statement
          2. if...else if...else statement
          3. Nested if statement
          4. Switch statement
        2. Iteration statement
          1. The do...while loop
          2. The while loop
          3. The for loop
          4. The foreach loop
        3. The jump statement
          1. break
          2. continue
          3. default
        4. Exception-handling statement
    6. Arrays and string manipulations
      1. Arrays
      2. Types of arrays
        1. Single-dimensional array
        2. Multidimensional array
        3. Jagged array
      3. Strings
    7. Structure versus class
    8. Hands-on exercise
    9. Revisiting day 2
  4. Day 03 - What's New in C#
    1. Tuples and deconstruction
      1. Tuples
        1. The System.ValueTuple struct
      2. Deconstruction
      3. Tuple – important points to remember
    2. Pattern matching
      1. is expression
      2. switch statement
        1. constant pattern
        2. type pattern
        3. When clause in case expression
    3. Local functions
    4. Literal improvements
      1. Binary literals
      2. Digit separator
    5. Async Main
      1. Restrictions while using new signatures
    6. Default expressions
      1. Member variables
        1. Constants
    7. Infer tuple names
    8. Other features supposed to release
      1. Pattern-matching with generics
      2. Reference assemblies
    9. Hands-on exercises
    10. Revisiting Day 03
  5. Day 04 - Discussing C# Class Members
    1. Modifiers
      1. Access modifiers and accessibility levels
        1. public
        2. protected
        3. internal
        4. composite
        5. private
      2. Rules for the access modifier
      3. abstract
        1. Rules of the abstract modifier
      4. async
      5. const
      6. event
      7. extern
      8. new
      9. override
      10. partial
      11. readonly
      12. sealed
      13. static
        1. Rules for the static modifier
      14. unsafe
      15. virtual
    2. Methods
      1. How to use a method?
    3. Properties
      1. Types of properties
        1. Read-write property
        2. Read-only property
        3. Computed property
          1. Block-bodied members
          2. Expression-bodied members
        4. Property using validation
    4. Indexers
    5. File I/O
      1. FileStream
    6. Exception handling
      1. try block
      2. catch block
      3. finally block
        1. Different compiler-generated exceptions in catch block
      4. User-defined exceptions
    7. Discussing a regular expression and its importance
      1. The Importance of a regular expression
        1. Flexible
        2. Constructs
        3. Special characters
          1. The period sign (.)
          2. The word sign (w)
          3. The space sign (s)
          4. The digit sign (d)
          5. The hyphen sign (-)
          6. Specifying the number of matches
    8. Hands-on exercise
    9. Revisiting Day 04
  6. Day 05 - Overview of Reflection and Collections
    1. What is reflection?
      1. Reflection in use
        1. Getting type info
    2. Overview of delegates and events
      1. Delegates
        1. Declaring a delegate type
        2. Instances of delegate
        3. Delegates in use
      2. Events
        1. Declaring an event
    3. Collections and non-generics
      1. ArrayList
        1. Declaration of ArrayList
          1. Properties
          2. Methods
      2. HashTable
        1. Declaration of HashTable
          1. Properties
          2. Methods
      3. SortedList
        1. Declaration of SortedList
          1. Properties
          2. Methods
      4. Stack
        1. Declaration of Stack
          1. Properties
          2. Methods
      5. Queue
        1. Declaration of Queue
          1. Properties
          2. Methods
      6. BitArray
    4. Hands - on exercise
    5. Revisiting Day 05
  7. Day 06 - Deep Dive with Advanced Concepts
    1. Playing with collections and generics
      1. Understanding collection classes and their usage
      2. Performance - BitArray versus boolArray
      3. Understanding generics and their usage
        1. Collections and generics
        2. Why should we use generics?
        3. Discussing constraints
          1. The value type
          2. The reference type
          3. The default constructor
          4. The base class constraint
          5. The interface constraint
    2. Beautifying code using attributes
      1. Types of attributes
        1. AttributeUsage
        2. Obsolete
        3. Conditional
      2. Creating and implementing a custom attribute
        1. Prerequisites
    3. Leveraging preprocessor directives
      1. Important points
        1. Preprocessor directives in action
    4. Getting started with LINQ
    5. Writing unsafe code
    6. Writing asynchronous code
    7. Hands-on exercises
    8. Revisiting Day 6
  8. Day 07 - Understanding Object-Oriented Programming with C#
    1. Introduction to OOP
    2. Discussing Object relations
    3. Inheritance
      1. Understanding inheritance
        1. Types of inheritance
        2. Member visibility in inheritance
      2. Implementing inheritance
        1. Implementing multiple inheritance in C#
    4. Abstraction
      1. Implementing abstraction
        1. Abstract class
          1. Features of abstract class
        2. Interface
          1. Features of interface
    5. Encapsulation
      1. What are access modifier in C#?
      2. Implementing encapsulation
    6. Polymorphism
      1. Types of polymorphism
      2. Implementing polymorphism
    7. Hands on Exercise
    8. Revisiting Day 7
    9. What next?
  9. Day 08 - Test Your Skills – Build a Real-World Application
    1. Why are we developing this application?
    2. Getting started with application development
      1. Prerequisites
      2. The database design
        1. Overview
    3. Discussing the basic architecture
    4. Revisiting day 08

Product information

  • Title: Learn C# in 7 days
  • Author(s): Gaurav Aroraa
  • Release date: October 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781787287044