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

Writing unsafe code


In this section, we will discuss introduction to how to write unsafe code using Visual Studio. Language C# provides a way to write code which compiles and creates the objects and these objects under the root are managed by the garbage collector [refer to day 01 for more details on garbage collector]. In simple words, C# is not like C, C++ language which use concept of function pointer to access references. But there is a situation when it is necessary to use function-pointers in C# language similar to languages that support function-pointers like C or C++ but C# language does not support it. To overcome such situations, we have unsafe code in C# language. There is modifier unsafe which tells that this code is not controlled by Garbage collector and within that block we can use function pointers and other unsafe stuffs. To use unsafe code, we first inform compiler to set on unsafe compilation from Visual Studio 2017 or later just go to project properties and on Build tab...