Mastering C#: A Beginner's Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Learning a new programming language might seem like a challenging task. You may have looked at coding in the past and felt it was too confusing and big to tackle. Mastering C#: A Beginner’s Guide will take you, step by step, through the process of learning one of the best programming languages out there. In a matter of no time, you will be able to write code like a professional.

C# is one of the most widely used programming languages available – and for a good reason. Developed by Microsoft, it has a simplified syntax, type safety, garbage collection, cross-language capabilities, and developer support. It offers high productivity of rapid application development languages with the dynamic power of C and C++. Updated to cover the new features of C#, including dynamic binding, named and optional parameters, and covariant and contravariant generic types, Mastering C# takes the language to the next level by promoting the ability to cleanly run programs that don’t rely on static type definitions.

In this book, concepts are broken down into simple steps to make sure that you can easily master the C# language, even if you have never tried coding. Carefully selected C# examples illustrate all concepts. In addition, the output for all examples are provided immediately, so you do not have to wait untilyou have access to your computer to test the examples. Topics are handpicked to give you proper exposure to C#, while not overwhelming with too much information.

Mastering C# also covers the fundamentals of programming. It teaches you how to define and use variables, how to manage primitive data structures (such as numbers), how to organize logical statements, how to print on the console, how to apply arrays, work with numeral systems, how to set and use methods, and how to create objects. Along with the basic programming knowledge, Mastering C# will help you understand more complicated concepts, including string processing, exception handling, using complex data structures (like trees and hash tables), defining custom classes, and working with LINQ queries. The concepts of object-oriented programming (OOP) – an established approach in modern software development – is covered in depth as well.

Moreover, you will get a complete methodology for solving programming problems as well as algorithmic problems in general. This gives you the opportunity to become a master programmer who has in-depth knowledge of programming and technology. After you acquire the fundamentals of programming, it will become much easier for you to read and learn databases and web applications, and you will understand what you read of the new material much easier rather than if you directly begin learning SQL, ASP.NET, AJAX, XAML, or WinRT.

All in all, Mastering C# is the definitive, must-have reference for any developer who wants to understand C#. This knowledge will enable you to turn your original and imaginative ideas into a real-world practical application.

Author(s): Mohamed Musthafa MC, Divya Sachdeva, Reza Nafim
Series: Mastering Computer Science
Publisher: CRC Press
Year: 2022

Language: English
Pages: 326
City: Boca Raton

Cover
Half Title
Series Page
Title Page
Copyright Page
Contents
About the Editor
CHAPTER 1: Mastering C# Programming Language—A Beginner’s Guide
INTRODUCTION TO C# PROGRAMMING LANGUAGE
WHAT IS C#
WHY C# MATTERS
HISTORY OF C#
C# Version 1.0
C# Version 1.2
C# Version 2.0
C# Version 3.0
C# Version 4.0
C# Version 5.0
C# Version 6.0
C# Version 7.0
C# Version 7.1
C# Version 7.2
C# Version 7.3
C# Version 8.0
C# Version 9.0
UNDERSTANDING THE BASIC STRUCTURE OF THE C# PROGRAM
USING KEYWORD
NAMESPACE
CLASS
Access Modifiers
METHOD
CONSTRUCTOR
DATA TYPES
CURLY BRACES
CHAPTER 2: Building Blocks of C#
MEMBERS
Accessibility
Fields
Methods
Parameters
Method Body and Local Variables
Static and Instance Methods
Method Overloading
Other Function Members
Constructors
Events
Operators
Finalizers
Expressions
Statements
UNDERSTANDING THE CLI
Common Type System
Common Language Specification
Metadata
Virtual Execution System
THE .NET FRAMEWORKS
CLR
Framework Class Library (FCL)
App Models
Why Do Companies Use .NET?
.NET Framework for Users
Important Points
What Languages Do Developers Have Access to While Working with .NET?
ASSEMBLIES IN .NET
GAC
Assembly Manifest
What Are the Benefits of Using Assemblies?
Versioning Problems
DLL Conflicts
The Solution
How Does It Work?
CHAPTER 3: Data Types and Operators
VALUE DATA TYPE
REFERENCE DATA TYPE
Pointer Data Type
Operators
BASIC DATA TYPES IN C#
Integer
Double
Boolean
String
VARIABLES
Local Variables
Instance Variables or Non-Static Variables
Static Variables or Class Variables
Difference between Instance Variable and Static Variable
Constants Variables
Read-Only Variables
CONSTANTS
Which Types Can Be Used as a Constant?
A Constant Alternative: The Read-Only Field
REFERENCE TYPE AND VALUE TYPES
ARRAYS AND OPERATORS
OPERATORS
Arithmetic Operators
Relational Operators
Logical Operators
Assignment Operators
CHAPTER 4: Exploring User-Defined Types
CLASSES AND OBJECTS
System Classes
Creating and Using Objects
Releasing the Objects
Access to Fields of an Object
Access to the Memory and Properties of an Object—Example
Calling Methods of Objects
Calling Methods of Objects—Example
CONSTRUCTORS
Constructor with Parameters
Calling Constructors—Example
When to Use Static Fields and Methods
Static Fields and Methods—Example
STRUCTURES
Structs with Methods
Structs and Constructors
Nested Structs
ENUMERATION
NAMESPACES
Nested Namespaces
CHAPTER 5: Object-Oriented Programming in C#
WHAT IS OOP
Basic Principles Concept in C# Programming
Structure of OOP
Class
Objects
Method
Encapsulation
Abstract Classes
Inheritance
Polymorphism
IMPLEMENTATION OF OOP
Encapsulation
Inheritance
Polymorphism
Reusability
Compiling the Program
Classes and Objects
Multiple Class Declaration
Partial Classes
Static Classes
Constructor and Destructor
Static Constructor
Destructors
Function Overloading
Virtual Methods
Hiding Methods
Abstract Classes
Sealed Classes
Interface
ENCAPSULATION AND INHERITANCE
Advantages of Encapsulation
Inheritance
Types of Inheritance in C#
Advantages of Inheritance in C#
Why Use Inheritance and How It Makes It Easy to Work?
CONCLUSION
CHAPTER 6: Generics in C#
WHAT ARE GENERICS
Characteristics of Generics
Type Safety
Performance
Binary Code Reuse
Generic Methods
Generic Class and Methods
C# Constraint
C# Multiple Constraints
GENERIC TYPES AND METHODS
Generic Types
Constraints
Type Constraints
Reference Type Constraints
Value Type Constraints
Value Types Down with Unmanaged Constraints
Not Null Constraints
Other Special Type Constraints
Multiple Constraints
Type Inference
COVARIANCE AND CONTRAVARIANCE IN GENERICS
Generic Interfaces with Contravariant Type Parameters
CHAPTER 7: Functional Programming and Lambdas in C#
FUNCTIONAL PROGRAMMING
Benefits of Functional Programming
Function Types
Function Arithmetic
C# Functional Programming
Higher-Order Functions
Asynchronous Functions
Asynchronous Functions with CallbacksIn
Tuples
Closures
LAMBDA EXPRESSION
Async Lambdas
Variable Scope in Lambda Expression
Statement Lambda
LINQ
Advantages of LINQ Include the Following:
Namespace
Filtering
Distinct
Aggregation
Method Chaining
Existence Operations
Intersection
Union
Except
Grouping
CHAPTER 8: Dynamic Programming and Reflection
ADVANTAGES OF DYNAMIC AND STATIC LANGUAGES
Recursion vs. Dynamic Programming
Recursion vs. Iteration
Approaches of Dynamic Programming
Top-Down Approach
Advantages
Bottom-Up Approach
Key Points
DYNAMIC PROGRAMMING IN C#
How to Use Dynamic
Dynamic and Overloading of Methods
Conclusion
UNDERSTANDING REFLECTION
Defining Reflection in C#
A Simple Use Case
How Reflection in C# Works
Uses for Reflection C#
USING DYNAMIC TYPE
How Does Dynamic Type Work?
Short Overview of DLR
Call Ste Caching
Expression Trees
Dynamic Object Interoperability
Why Should We Use the Dynamic Type
Dynamic vs. Reflection
Var vs. Object vs. Dynamic
Var Keyword
Object Keyword
Dynamic Keyword
APPRAISAL
INDEX