Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learn C# Programming
Learn C# Programming

Learn C# Programming: A guide to building a solid foundation in C# language for writing efficient programs

Arrow left icon
Profile Icon Marius Bancila Profile Icon Tripathi Profile Icon Rialdi Profile Icon Ankit Sharma
Arrow right icon
R$80 R$196.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (4 Ratings)
eBook Apr 2020 636 pages 1st Edition
eBook
R$80 R$196.99
Paperback
R$245.99
Subscription
Free Trial
Renews at R$50p/m
Arrow left icon
Profile Icon Marius Bancila Profile Icon Tripathi Profile Icon Rialdi Profile Icon Ankit Sharma
Arrow right icon
R$80 R$196.99
Full star icon Full star icon Full star icon Full star icon Full star icon 5 (4 Ratings)
eBook Apr 2020 636 pages 1st Edition
eBook
R$80 R$196.99
Paperback
R$245.99
Subscription
Free Trial
Renews at R$50p/m
eBook
R$80 R$196.99
Paperback
R$245.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learn C# Programming

Chapter 2: Data Types and Operators

In the previous chapter, we learned about .NET Framework and understood the basic structure of a C# program. In this chapter, we will learn about data types and objects in C#. Alongside control statements, which we will explore in the next chapter, these are the building blocks of every program. We will discuss built-in data types, explain the difference between value types and reference types, and learn how to convert between types. We will also discuss the operators defined by the language as we move on.

The following topics will be covered in this chapter:

  • Basic built-in data types
  • Variables and constants
  • Reference types and value types
  • Nullable type
  • Arrays
  • Type conversion
  • Operators

By the end of this chapter, you will be able to write a simple C# program using the aforementioned language features.

Basic data types

In this section, we will explore the basic data types. The Common Language Infrastructure (CLI) defines a set of standard types and operations that are supported by all programming languages targeting the CLI. These data types are provided in the System namespace. All of them, however, have a C# alias. These aliases are keywords in the C# language, which means they can only be used in the context of their designated purpose and not elsewhere, such as variable, class, or method names. The C# name and the .NET name, along with a short description of each type, are listed in the following table (listed alphabetically by the C# name):

The types listed in this table are called simple types or primitive types. Apart from these, there are two more built-in types:

Let's explore all of the primitive types in detail in the following sections.

The integral types

C# supports eight integer types that represent various ranges of integral numbers. The bits and range of each of them are shown in the following table:

As shown in the preceding table, C# defines both signed and unsigned integer types. The major difference between signed and unsigned integers is the way in which the high order bit is read. In the case of a signed integer, the high order bit is considered the sign flag. If the sign flag is 0, then the number is positive but if the sign flag is 1, then the number is negative.

The default value of all integral types is 0. All of these types define two constants called MinValue and MaxValue, which provide the minimum and maximum value of the type.

Integral literals, which are numbers that appear directly in code (such as 0, -42, and so on), can be specified as decimal, hexadecimal, or binary literals. Decimal literals do not require any suffix. Hexadecimal literals are prefixed with 0x or 0X, and binary literals are prefixed with 0b or 0B. An underscore (_) can be used as a digit separator with all numeric literals. Examples of such literals are shown in the following snippet:

int dec = 32;
int hex = 0x2A;
int bin = 0b_0010_1010;

An integral value without any suffix is inferred by the compiler as int. To indicate a long integer, use l or L for a signed 64-bit integer and ul or UL for an unsigned 64-bit integer.

The floating-point types

The floating-point types are used to represent numbers having fractional components. C# defines two floating-point types, as shown in the following table:

The float type represents a 32-bit, single-precision floating-point number, whereas double represents a 64-bit, double-precision floating-point number. These types are implementations of the IEEE Standard for Floating-Point Arithmetic (IEEE 754), which is a standard established by the Institute of Electrical and Electronics Engineers (IEEE) in 1985 for floating-point arithmetic.

The default value for floating-point types is 0. These types also define two constants called MinValue and MaxValue that provide the minimum and maximum value of the type. However, these types also provide constants that represent not-a-number (System.Double.NaN) and infinity (System.Double.NegativeInfinity and System.Double.PositiveInfinity). The following code listing shows several variables initialized with floating-point values:

var a = 42.99;
float b = 19.50f;
System.Double c = -1.23;

By default, a non-integer number such as 42.99 is considered a double. If you want to specify this as a float type, then you need to suffix the value with the f or F character, such as in 42.99f or 42.99F. Alternatively, you can also explicitly indicate a double literal with the d or D suffix, such as in 42.99d or 42.99D.

Floating-point types store fractional parts as inverse powers of two. For this reason, they can only represent exact values such as 10, 10.25, 10.5, and so on. Other numbers, such as 1.23 or 19.99, cannot be represented exactly and are only an approximation. Even if double has 15 decimal digits of precision, as compared to only 7 for float, precision loss starts to accumulate when performing repeated calculations.

This makes double and float difficult or even inappropriate to use in certain types of applications, such as financial applications, where precision is key. For this purpose, the decimal type is provided.

The decimal type

The decimal type can represent up to 28 decimal places. The details for the decimal type are shown in the following table:

The default value for the decimal type is 0. MinValue and MaxValue constants that define the minimum and maximum value of the type are also available. A decimal literal can be specified using the m or M suffix as shown in the following snippet:

decimal a = 42.99m;
var b = 12.45m;
System.Decimal c = 100.75M;

It is important to note that the decimal type minimizes errors during rounding but does not eliminate the need for rounding. For instance, the result of the operation 1m / 3 * 3 is not 1 but 0.9999999999999999999999999999. On the other hand, Math.Round(1m / 3 * 3) yields the value 1.

The decimal type is designed for use in applications where precision is key. Floats and doubles are much faster types (because they use binary math, which is faster to compute), while the decimal type is slower (as the name implies, it uses decimal math, which is slower to compute). The decimal type can be an order of magnitude slower than the double type. Financial applications, where small inaccuracies can accumulate to important values over repeated computations, are a typical use case for the decimal type. In such applications, speed is not important, but precision is.

The char type

The character type is used to represent a 16-bit Unicode character. Unicode defines a character set that is intended to represent the characters of most languages in the world. Characters are represented by enclosing them in single quotation marks (''). Examples of this include 'A', 'B', 'c' and '\u0058':

Character values can be literals, hexadecimal escape sequences that have the form '\xdddd', or Unicode representations that have the form '\udddd' (where dddd is a 16 hexadecimal value). The following listing shows several examples:

char a = 'A';
char b = '\x0065';
char c = '\u15FE';

The default value for the char type is decimal 0, or its equivalents, '\0', '\x0000', or '\u0000'.

The bool type

C# uses the bool keyword to represent the Boolean type. It can have two values, true or false, as shown in the following table:

The default value for the bool type is false. Unlike other languages (such as C++), integer values or any other values do not implicitly convert into the bool type. A Boolean variable can be either assigned a Boolean literal (true or false) or an expression that evaluates to bool.

The string type

A string is an array of characters. In C#, the type for representing a string is called string and is an alias for the .NET System.String. You can use any of these two types interchangeably. Internally, a string contains a read-only collection of char objects. This makes strings immutable, which means that you cannot change a string but need to create a new one every time you want to modify the content of an existing string. Strings are not null-terminated (unlike other languages such as C++) and can contain any number of null characters ('\0'). The string length will contain the total number of the char objects.

Strings can be declared and initialized in a variety of ways, as shown here:

string s1;                       // unitialized
string s2 = null;                // initialized with null
string s3 = String.Empty;        // empty string
string s4 = "hello world";       // initialized with text
var s5 = "hello world";
System.String s6 = "hello world";
char[] letters = { 'h', 'e', 'l', 'l', 'o'};
string s7 = new string(letters); // from an array of chars

It is important to note that the only situation when you use the new operator to create a string object is when you initialize it from an array of characters.

As mentioned before, strings are immutable. Although you have access to the characters of the string, you can read them, but you cannot change them:

char c = s4[0];  // OK
s4[0] = 'H';     // error

The following are the methods that seem to be modifying a string:

  • Remove(): This removes a part of the string.
  • ToUpper()/ToLower(): This converts all of the characters into uppercase or lowercase.

Neither of these methods modifies the existing string, but instead returns a new one.

In the following example, s6 is the string defined earlier, s8 will contain hello, s9 will contain HELLO WORLD, and s6 will continue to contain hello world:

var s8 = s6.Remove(5);       // hello
var s9 = s6.ToUpper();       // HELLO WORLD

You can convert any built-in type, such as integer or floating-point numbers, into a string using the ToString() method. This is actually a virtual method of the System.Object type, that is, the base class for any .NET type. By overriding this method, any type can provide a way to serialize an object to a string:

int i = 42;
double d = 19.99;
var s1 = i.ToString();
var s2 = d.ToString();

Strings can be composed in several ways:

  • It can be done using the concatenating operator, +.
  • Using the Format() method: The first argument of this method is the format, in which each parameter is indicated positionally with the index specified in curly braces, such as {0}, {1}, {2}and so on. Specifying an index beyond the number of arguments results in a runtime exception.
  • Using string interpolation, which is practically a syntactic shortcut for using the String.Format() method: The string must be prefixed with $ and the arguments are specified directly in curly braces.

An example of all of these methods is shown here:

int i = 42;
string s1 = "This is item " + i.ToString();
string s2 = string.Format("This is item {0}", i);
string s3 = $"This is item {i}";

Some characters have a special meaning and are prefixed with a backslash (\). These are called escaped sequences. The following table lists all of them:

Escape sequences are necessary in certain cases, such as when you specify a Windows file path or when you need a text that spawns multiple lines. The following code shows several examples where escape sequences are used:

var s1 = "c:\\Program Files (x86)\\Windows Kits\\";
var s2 = "That was called a \"demo\"";
var s3 = "This text\nspawns multiple lines.";

You can, however, avoid using escape sequences by using verbatim strings. These are prefixed with the @ symbol. When the compiler encounters such a string, it does not interpret escape sequences. If you want to use quotation marks in a string when using verbatim strings, you must double them. The following sample shows the preceding examples rewritten with verbatim strings:

var s1 = @"c:\Program Files (x86)\Windows Kits\";
var s2 = @"That was called a ""demo""";
var s3 = @"This text
spawns multiple lines.";

Prior to C# 8, if you wanted to use string interpolation with verbatim strings, you had to first specify the $ symbol for string interpolation and then @ for verbatim strings. In C# 8, you can specify these two symbols in any order.

The object type

The object type is the base type for all other types in C#, even though you do not specify this explicitly, as we will see in the following chapters. The object keyword in C# is an alias for the .NET System.Object type. You can use these two interchangeably.

The object type provides some basic functionalities to all other classes in the form of several virtual methods that any derived class can override, if necessary. These methods are listed in the following table:

Apart from these, the object class contains several other methods. An important one to note is the GetType() method, which is not virtual and which returns a System.Type object with information about the type of the current instance.

Another important thing to notice is the way the Equals() method works because its behavior is different for reference and value types. We have not covered these concepts yet but will do so later in this chapter. For the time being, keep in mind that, for reference types, this method performs reference equality; this means it checks whether the two variables point to the same object on the heap. For value types, it performs value equality; this means that the two variables are of the same type and that the public and private fields of the two objects are equal.

The object type is a reference type. The default value of a variable of the object type is null. However, a variable of the object type can be assigned any value of any type. When you assign a value type value to object, the operation is called boxing. The reverse operation of converting the value of object into a value type is called unboxing. This will be detailed in a later section in this chapter.

You will learn more about the object type and its methods throughout this book.

Variables

Variables are defined as a named memory location that can be assigned to a value. There are several types of variables, including the following:

  • Local variables: These are variables that are defined within a method and their scope is local to that method.
  • Method parameters: These are variables that hold the arguments passed to a method during a function call.
  • Class fields: These are variables that are defined in the scope of the class and are accessible to all of the class methods and depending on the accessibility of the field to other classes too.
  • Array elements: These are variables that refer to elements in an array.

In this section, we will refer to local variables, which are variables declared in the body of a function. Such variables are declared using the following syntax:

datatype variable_name;

In this statement, datatype is the data type of the variable and variable_name is the name of the variable. Here are several examples:

bool f;
char ch = 'x';
int a, b = 20, c = 42;
a = -1;
f = true;

In this example, f is an uninitialized bool variable. Uninitialized variables cannot be used in any expression. An attempt to do so will result in a compiler error. All variables must be initialized before they are used. A variable can be initialized when declared, such as with ch, b, and c in the preceding example, or at any later time, such as with a and f.

Multiple variables of the same type can be declared and initialized in a single statement, separated by a comma. This is exemplified in the preceding code snippet with the int variables a, b, and c.

Naming convention

There are several rules that must be followed for naming a variable:

  • Variable names can consist of letters, digits, and underscore characters (_) only.
  • You cannot use any special character other than underscore (_) when naming a variable. Consequently, @sample, #tag, name%, and so on are illegal variable names.
  • The variable name must begin with a letter or an underscore character (_). The name of the variable cannot start with a digit. Therefore, 2small as a variable name will throw a compile-time error.
  • Variable names are case-sensitive. Therefore, person and PERSON are considered two different variables.
  • A variable name cannot be any reserved keyword of C#. Hence true, false, double, float, var, and so on are illegal variable names. However, prefixing a keyword with @ enables the compiler to treat them as identifiers, rather than keywords. Therefore, variables names such as @true, @return, @var are allowed. These are called verbatim identifiers.
  • Apart from the language rules that you must follow when naming variables, you should also make sure the names you choose are descriptive and easy to understand. You should always prefer that over short, abbreviated names that are hard to comprehend. There are various coding standards and naming conventions and you should adhere to one. These promote consistency and make the code easier to read, understand, and maintain.

When it comes to naming conventions, you should do the following when programming in C#:

  • Use pascal case for classes, structures, enums, delegates, constructors, methods, properties, and constants. In Pascal case, each word in a name is capitalized; examples include ConnectionString, UserGroup, and XmlReader.
  • Use camel case for fields, local variables, and method parameters. In camel case, the first word of a name is not capitalized, but all of the others are; examples include userId, xmlDocument, and uiControl.
  • Do not use underscore in identifiers unless to prefix private fields, such as in _firstName, and_lastName.
  • Prefer descriptive name over abbreviations. For example, prefer labelText over lbltxt or employeeId over eid.

You can learn more about coding standards and naming conventions in C# by consulting additional resources.

Implicity-typed variables

As we have seen in previous examples, we need to specify the type of a variable when we are declaring it. However, C# provides us with another way to declare variables that allows the compiler to infer the variable type based on the value assigned to it during initialization. These are known as implicitly typed variables.

We can create an implicitly typed variable using the var keyword. Such variables must always be initialized on the declaration because the compiler infers the type of the variable from the value that it is initialized with. Here is an example:

var a = 10;

Since the a variable is initialized with an integer literal, a is considered as an int variable by the compiler.

When declaring variables with var, you must keep in mind the following:

  • An implicitly typed variable must be initialized to a value at the time of declaration, otherwise, the compiler has no reference to infer the variable type and it results in a compile-time error.
  • You cannot initialize it to null.
  • The variable type cannot be changed once it is declared and initialized.

    Information box

    The var keyword is not a datatype but a placeholder for an actual type. Using var to declare variables is useful when the type name is long and you want to avoid typing a lot (for example, Dictionary<string, KeyValuePair<int, string>>) or you do not care about the actual type, only the value.

Now that you learned how you can declare variables, let's look at a key concept: the scope of variables.

Understanding the scope and lifetime of variables

A scope in C# is defined as a block between an opening curly brace and its corresponding closing curly brace. The scope defines the visibility and lifetime of a variable. A variable can be accessed only within the scope in which it is defined. A variable that is defined in a particular scope is not visible to the code outside that scope.

Let's understand this with the help of an example:

class Program
{
    static void Main(string[] args)
    {
        for (int i = 1; i < 10; i++)
        {
            Console.WriteLine(i);
        }
        i = 20; // i is out of scope
    }
}

In this example, the i variable is defined inside the for loop, hence it cannot be accessed outside the for loop as it goes out of scope once the control exits the loop. You will learn more about the for loop in the next chapter.

We can also have nested scopes. This means a variable defined in a scope can be accessed in another scope that is enclosed in that scope. However, the variables from the outer scope are visible to the inner scope but the inner scope variables are not accessible in the outer scope. The C# compiler won't allow you to create two variables with the same name within a scope.

Let's extend the code in the previous example to understand this:

class Program
{
    static void Main(string[] args)
    {
        int a = 5;
        for (int i = 1; i < 10; i++)
        {
            char a = 'w';                 // compiler error
            if (i % 2 == 0)
            {
                Console.WriteLine(i + a); // a is within the 
                                          // scope of Main
            }
        }
        i = 20;                           // i is out of scope
    }
}

Here, the integer variable a is defined outside the for loop but within the scope of Main. Hence, it can be accessed within the for loop as it is in the scope of this. However, the i variable, which is defined inside the for loop, cannot be accessed inside the scope of Main.

If we try to declare another variable with the same name in the scope, we will get a compile-time error. Consequently, we cannot declare a character variable a inside the for loop as we already have an integer variable with the same name.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn the fundamentals of C# with the help of easy-to-follow examples and explanations
  • Leverage the latest features of C# 8, including nullable reference types, pattern matching enhancements, and asynchronous streams
  • Explore object-oriented programming, functional programming, and multithreading concepts

Description

The C# programming language is often developers’ primary choice for creating a wide range of applications for desktop, cloud, and mobile. In nearly two decades of its existence, C# has evolved from a general-purpose, object-oriented language to a multi-paradigm language with impressive features. This book will take you through C# from the ground up in a step-by-step manner. You'll start with the building blocks of C#, which include basic data types, variables, strings, arrays, operators, control statements, and loops. Once comfortable with the basics, you'll then progress to learning object-oriented programming concepts such as classes and structures, objects, interfaces, and abstraction. Generics, functional programming, dynamic, and asynchronous programming are covered in detail. This book also takes you through regular expressions, reflection, memory management, pattern matching, exceptions, and many other advanced topics. As you advance, you'll explore the .NET Core 3 framework and learn how to use the dotnet command-line interface (CLI), consume NuGet packages, develop for Linux, and migrate apps built with .NET Framework. Finally, you'll understand how to run unit tests with the Microsoft unit testing frameworks available in Visual Studio. By the end of this book, you’ll be well-versed with the essentials of the C# language and be ready to start creating apps with it.

Who is this book for?

If you have little experience in coding or C# and want to learn the essentials of C# programming to develop powerful programming techniques, this book is for you. It will also help aspiring programmers to write scripts or programs to accomplish specific tasks.

What you will learn

  • Get to grips with all the new features of C# 8
  • Discover how to use attributes and reflection to build extendable applications
  • Utilize LINQ to uniformly query various sources of data
  • Use files and streams and serialize data to JSON and XML
  • Write asynchronous code with the async-await pattern
  • Employ .NET Core tools to create, compile, and publish your applications
  • Create unit tests with Visual Studio and the Microsoft unit testing frameworks

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 30, 2020
Length: 636 pages
Edition : 1st
Language : English
ISBN-13 : 9781789808445
Vendor :
Microsoft
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 30, 2020
Length: 636 pages
Edition : 1st
Language : English
ISBN-13 : 9781789808445
Vendor :
Microsoft
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 981.97
C# 10 and .NET 6 – Modern Cross-Platform Development
R$445.99
Learn C# Programming
R$245.99
Clean Code in C#
R$289.99
Total R$ 981.97 Stars icon

Table of Contents

19 Chapters
Chapter 1: Starting with the Building Blocks of C# Chevron down icon Chevron up icon
Chapter 2: Data Types and Operators Chevron down icon Chevron up icon
Chapter 3: Control Statements and Exceptions Chevron down icon Chevron up icon
Chapter 4: Understanding the Various User-Defined Types Chevron down icon Chevron up icon
Chapter 5: Object-Oriented Programming in C# Chevron down icon Chevron up icon
Chapter 6: Generics Chevron down icon Chevron up icon
Chapter 7: Collections Chevron down icon Chevron up icon
Chapter 8: Advanced Topics Chevron down icon Chevron up icon
Chapter 9: Resource Management Chevron down icon Chevron up icon
Chapter 10: Lambdas, LINQ, and Functional Programming Chevron down icon Chevron up icon
Chapter 11: Reflection and Dynamic Programming Chevron down icon Chevron up icon
Chapter 12: Multithreading and Asynchronous Programming Chevron down icon Chevron up icon
Chapter 13: Files, Streams, and Serialization Chevron down icon Chevron up icon
Chapter 14: Error Handling Chevron down icon Chevron up icon
Chapter 15: New Features of C# 8 Chevron down icon Chevron up icon
Chapter 16: C# in Action with .NET Core 3 Chevron down icon Chevron up icon
Chapter 17: Unit Testing Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(4 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Cliente Amazon Nov 03, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Da regalare a mio Figlio per lo studio universitario sui linguaggi ad oggetti e in particolare C#. D'altronde sec come Co-Autore c'è il Mitico Raf allora è una garanzia. WeLoveRaf!!!
Amazon Verified review Amazon
Keerthi Jan 25, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Honestly I despise Packt due to bad experiences in the past. But this book is an exception.I come from the Java world and was looking to get started on the .NET platform to build micro-services in C# for a project requirement. After trying a couple of books on the topic from O'Reilly and disappointed picked this one half-heatedly.This book blew the rest out of the water easily. Concepts that the other books struggle to explain or not explained well enough are dealt with in a lucid and clear manner. The authors communicate more with less words. The breadth and depth of coverage is also good and, most importantly, is free from fluff. Highly recommended!Would never judge a book by its cover, ever!
Amazon Verified review Amazon
S. Barth Aug 02, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I bought this book for my grandson who is learning Unity game development. (Unity uses C# as the code base.) The book arrived quickly, in perfect shape, and will be a great asset / resource as we start off his developer's library with it. A good purchase all the way around!
Amazon Verified review Amazon
Thomas Seabrook Jul 19, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was in need of learning the basics and some intermediate topics of C# and so far this book hasn't dissapointed. After looking through some underwhelming reviews of similar books I stumbled across this one and though it was worth a go. So far I haven't been dissapointed. The book is well written and doesn't waste much time before getting into the learning content (there's a chapter on the history of the language). Overall this is a great read for anyone starting to learn C# and I can myself reffering to this book for a long while.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.