Book Image

Learn C# in 7 days

By : Gaurav Aroraa
1 (1)
Book Image

Learn C# in 7 days

1 (1)
By: Gaurav Aroraa

Overview of this book

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#.
Table of Contents (15 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Properties


Properties are members of a class, structure, or interface generally called as a named member. The intended behaviors of properties are similar to fields with the difference being that the implementation of properties is possible with the use of accessors.

Note

Properties are extensions to fields. The accessors get and set helps retrieve and assign value to property.

Here is the typical property (also called property with auto-property syntax) of a class:

public int Number { get; set; }

For auto property, compiler generates the backup field, which is nothing but a storage field. So, the preceding property would be shown as follows, with a backup field:

private int _number;

public int Number
{
    get { return _number; }
    set { _number = value; }
}

The preceding property with an expression body looks like this:

private int _number;
public int Number
{
    get => _number;
    set => _number = value;
}

Note

For more details on the expression bodies property, refer to https://visualstudiomagazine...