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

Beautifying code using attributes


Attributes provide a way to associate information with code. This information could be as simple as a message/warning or can contain a complex operation or code itself. These are declared simply with the help of tags. These also help us to beautify our code by supplying inbuilt or custom attributes. Consider the following code:

private void PeerOperation() 
{ 
    //other stuffs 
    WriteLine("Level1 is completed."); 
    //other stuffs 
} 

In this method, we show an informational message to notify the peer. The preceding method will be decorated with the help of an attribute. Consider the following code:

[PeerInformation("Level1 is completed.")] 
private void PeerOperation() 
{ 
    //other stuffs 
} 

Now, we can see that we just decorated our method with the help of an attribute.

According to the official documentation [https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/attributes], attributes provide a way of associating information with code in a declarative...