Skip to content

This repository contains a collection of C# code examples designed to demonstrate various programming concepts and best practices. Each example is structured to provide clear, concise, and practical insights into different aspects of C# programming.

License

Notifications You must be signed in to change notification settings

oneananda/C_Sharp_Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# Examples Repository

This repository contains a collection of C# code examples designed to demonstrate various programming concepts and best practices. Each example is structured to provide clear, concise, and practical insights into different aspects of C# programming. The repository is suitable for beginners looking to understand the basics and for experienced developers seeking to explore advanced topics.

Features

  • Basic Syntax and Data Types: Examples covering fundamental C# syntax, data types, and control structures.
  • Object-Oriented Programming: Demonstrations of classes, inheritance, polymorphism, and encapsulation.
  • LINQ Queries: Practical examples of using LINQ for data manipulation and querying.
  • Asynchronous Programming: Code snippets illustrating async and await for concurrent programming.
  • Design Patterns: Implementation of common design patterns like Singleton, Factory, and Observer.
  • File I/O Operations: Examples of reading from and writing to files.
  • Error Handling: Techniques for exception handling and debugging.
  • Unit Testing: Sample tests using popular testing frameworks.
  • .NET Core Integration: Examples of building and running applications on .NET Core.
  • Advanced Programming Concepts: In-depth examples covering advanced topics such as reflection, generics, dependency injection, and multi-threading.

Getting Started

  1. Clone the repository:

    git clone https://github.com/oneananda/C_Sharp_Examples.git
  2. Navigate to the project directory:

    cd C_Sharp_Examples
  3. Open in your favorite IDE (e.g., Visual Studio, Visual Studio Code).

  4. Run the examples:

    • Follow the instructions provided in each example's README or comments.

Advanced_C_Sharp

A collection of advanced C# concepts, including in-depth explorations of features like delegates, events, generics, and LINQ. Perfect for developers looking to enhance their understanding of advanced C# programming techniques.

Advanced_SOLID_Patterns_Implementation

Demonstrates the implementation of SOLID principles with advanced design patterns. This project provides practical examples of how to apply SOLID principles in real-world scenarios to build maintainable and scalable software.

Async_Programming

Showcases asynchronous programming in C#, including the use of async/await, Task-based asynchronous patterns, and best practices for handling concurrency and performance optimization in .NET applications.

Beginners_Coding_Challenges

A set of beginner-friendly coding challenges designed to improve basic C# programming skills. Includes various problems with step-by-step solutions to help new developers build confidence in coding.

CQRS_Basic_Implementation

Provides a basic implementation of the Command Query Responsibility Segregation (CQRS) pattern. Includes examples of separating read and write operations to enhance scalability and maintainability of applications.

C_Sharp_12_Features

Covers new features introduced in C# 12, with examples showcasing their use and potential benefits. Ideal for developers looking to stay up-to-date with the latest language enhancements.

CancellationToken_Implementation

Explains how to implement and use CancellationToken in C# to manage task cancellation. Includes practical examples demonstrating how to gracefully handle task termination in asynchronous operations.

CopyConstructors

Illustrates the use of copy constructors in C#, providing examples on how to create deep and shallow copies of objects. Useful for developers looking to understand object cloning and data integrity.

Debugging

Covers essential debugging techniques in C#, including breakpoints, watches, and logging. Provides practical guidance on diagnosing and fixing bugs effectively using Visual Studio tools.

DefaultConstructors

A collection of examples demonstrating the use of default constructors in C#. Highlights the role of constructors in object initialization and class design.

Delegate_Deep_Dive

An in-depth exploration of delegates in C#, covering their usage, benefits, and real-world applications. Includes examples on event handling, callbacks, and building flexible code architectures.

Explicit_Conversions

Demonstrates explicit type conversions in C#, including user-defined conversions, type casting, and safe conversion practices. Provides examples to avoid common pitfalls and errors.

ExtensionMethods

Explores the concept of extension methods in C#, showing how to add functionality to existing types without modifying them. Includes practical use cases to enhance code readability and reusability.

Garbage_Collection

Provides a detailed overview of garbage collection in .NET, including the lifecycle of objects, memory management, and performance considerations. Offers insights into optimizing application performance by managing memory efficiently.

Implicit_Conversions

Covers implicit type conversions in C#, demonstrating how and when implicit conversions occur, along with guidelines to ensure type safety and maintain code clarity.

LINQ_Examples

A comprehensive set of LINQ examples showcasing various query operations, including filtering, ordering, grouping, and joining data. Ideal for developers seeking to master data manipulation using LINQ.

Lazy_Initialization_Vs_Dependency_Injection

Compares lazy initialization with dependency injection in C#, explaining their differences, use cases, and best practices. Provides examples to help choose the appropriate pattern for specific scenarios.

MediatR_Console_Implementation

A console application demonstrating the use of MediatR library in C#. Shows how to implement request/response patterns and decouple components using mediator patterns in .NET applications.

OOP_Examples_1

A series of examples illustrating core Object-Oriented Programming (OOP) concepts in C#, such as inheritance, polymorphism, encapsulation, and abstraction. Designed to reinforce fundamental OOP principles.

OutlookProgramming

Provides examples of programming with Outlook using C#, including reading and sending emails, managing calendar events, and accessing Outlook data through automation APIs.

Roslyn_Code_Parsing_Analysing

Demonstrates the use of Roslyn APIs for code parsing, analysis, and manipulation in C#. Includes examples of creating custom code analyzers and refactoring tools.

SOLID Principle Examples

A project dedicated to explaining each of the SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) with clear examples and best practices.

SOLID_Patterns_Implementation

Focuses on implementing SOLID principles with various design patterns in C#. Includes examples of applying patterns like Factory, Strategy, and Observer to adhere to SOLID design guidelines.

StaticConstructors

Explores the use of static constructors in C#, including when and why to use them. Provides examples to illustrate how static constructors initialize static members of a class.

String_Manipulation

A collection of string manipulation techniques in C#, including formatting, parsing, searching, and modifying strings. Designed to help developers handle string operations effectively.

T4_Template_Implementation

Shows how to use T4 templates in C# to generate code dynamically. Includes examples of generating repetitive code structures and automating code generation tasks in .NET projects.

Try_Catch_Finally_Deep_Dive

A deep dive into exception handling in C#, covering the try-catch-finally constructs. Provides examples of handling exceptions gracefully and implementing robust error handling strategies.

out_Deep_Dive

Explores the use of the out keyword in C#, including method overloading and returning multiple values. Provides examples and best practices for using out parameters effectively.

ref_Deep_Dive

A detailed exploration of the ref keyword in C#, showcasing how to pass arguments by reference. Includes examples to highlight when to use ref and the implications for method design.

ref_out_Deep_Comparision

Compares the use of ref and out keywords in C#, providing insights into their differences and appropriate use cases. Includes examples to clarify when to use each keyword.

var_Deep_Dive

A comprehensive guide to using var in C#, covering type inference, limitations, and best practices. Provides examples to help developers understand when and where to use var effectively.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue if you have suggestions for improvements or new examples.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Special thanks to the contributors and the C# community for their valuable input and support.

https://www.youtube.com/channel/UCSlA7v4u2-ARxQ-CPUj3UGw

About

This repository contains a collection of C# code examples designed to demonstrate various programming concepts and best practices. Each example is structured to provide clear, concise, and practical insights into different aspects of C# programming.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages