C#, a powerful and expressive programming language, is widely used in enterprise applications, games, and web development. It's crucial for developers to have a solid understanding of this language to make the most of its capabilities. One way to deepen your knowledge is through practical examples, and PDFs are an excellent format for presenting and learning from these. Let's delve into some key C# topics with examples, perfect for you to learn and explore.

Here, we'll focus on two main aspects: Object-Oriented Programming (OOP) and LINQ (Language Integrated Query). OOP is fundamental to C#, and LINQ is an essential tool for querying and manipulating data. We'll provide examples, use cases, and robust explanations to help you grasp these concepts fully.

Object-Oriented Programming in C#
OOP is a programming paradigm that organizes objects to design applications and systems. It's a fundamental part of C# and aids in creating modular, reusable, and maintainable code.

To master OOP in C#, it's essential to understand classes, objects, encapsulation, inheritance, and polymorphism. Let's explore these concepts with examples.
Classes and Objects

A class is a blueprint for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementations of behavior (member functions or methods).
For instance, a simple 'Car' class might look like this:
public class Car
{
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public void Display()
{
Console.WriteLine($"{Year} {Make} {Model}");
}
}
An object is an instance of a class. Here's how you'd create and use a Car object:

Car myCar = new Car { Make = "Toyota", Model = "Corolla", Year = 2022 };
myCar.Display(); // Outputs: 2022 Toyota Corolla
Encapsulation, Inheritance, and Polymorphism
These are advanced OOP concepts that help control data access, establish 'is-a' relationships, and enable method overriding. Explore them with PDF examples, such as creating an 'ElectricCar' class that inherits from 'Car' and overrides the 'Display' method to show battery information.
LINQ (Language Integrated Query)

LINQ extends C# with methods and keywords that make it possible to query data easily and efficiently. It's particularly useful when working with collections like List, Dictionary, or XML, allowing you to retrieve and manipulate data in a clear, readable way.
Let's consider two common LINQ methods: Where() and OrderBy(), with an example using a List of 'Car' objects.




















LINQ Where() Method
The Where() method filters a collection based on a given predicate. To find cars with 'Toyota' as the make:
List<Car> toyotas = cars.Where(car => car.Make == "Toyota").ToList();
LINQ OrderBy() Method
The OrderBy() method sorts a collection based on a given key selector. To order cars by year (ascending):
List<Car> orderedCars = cars.OrderBy(car => car.Year).ToList();
Explore these examples in-depth through PDF tutorials, delving into more LINQ methods and complex queries to solidify your understanding. Practice makes perfect, so don't hesitate to try these examples in your own coding environment.
C# is a robust and flexible language, and mastering its concepts and tools like OOP and LINQ can significantly improve your coding skills. Continue exploring with PDF examples, workshops, and online resources to take your learning to the next level. Happy coding, and remember to keep exploring and experimenting with C# examples!