Skip to content

This repository contains beginner-to-intermediate level exercises designed to strengthen your understanding of C# programming and ADO.NET. It covers setting up the development environment, exploring value vs reference types, working with C# 12 primary constructors, and demonstrating type inference using var and new().

Notifications You must be signed in to change notification settings

Chowdarysaritha311/C-ADO.NET-Exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


C# Programming Examples Collection

This repository contains a series of C# programs demonstrating various core and advanced features of the language. Each program targets a specific concept, designed to help you learn and understand modern C# features and best practices.


Programs Included

  1. Create and Use Records with init Properties

Demonstrates immutable record types using init properties.

Shows how to create modified copies with the with expression.

  1. Demonstrate Inheritance and Method Overriding

Explores class inheritance and method overriding.

Base class Shape with derived classes Circle and Rectangle.

  1. Differentiate Abstract Classes and Interfaces

Illustrates differences between abstract classes and interfaces.

Implements polymorphism using Vehicle abstract class and IDrivable interface.

  1. Handle Null References Safely

Shows safe handling of nullable reference types.

Uses null-conditional (?.) and null-coalescing (??) operators.

  1. Use Null-Conditional Chaining in a Contact App

Demonstrates null-conditional chaining to avoid null reference exceptions.

Implements a simple contact list example.

  1. Use the required Modifier in C# 12

Uses the new required modifier to enforce required properties at object initialization.

  1. Work with Lists and Dictionaries

Basic operations with List and Dictionary<K,V>.

Adding, removing, and iterating over collections.

  1. Use LINQ for Filtering and Projection

Uses LINQ queries to filter and project data from a list of orders.

  1. Use Pattern Matching with is and switch

Demonstrates type checking and pattern matching with is and enhanced switch.

  1. Create and Deconstruct Tuples

Returns multiple values using tuples.

Shows tuple deconstruction.

  1. Simulate Async File Upload with Exception Handling

Asynchronous method simulating file upload delay.

Exception handling using try-catch.

  1. Serialize and Deserialize JSON Files

Serializes an object to JSON and saves to a file.

Deserializes JSON back into an object.

  1. Use FileStream and MemoryStream

Reads text from a file using FileStream.

Writes to a MemoryStream and reports bytes written.

  1. Demonstrate Race Conditions with Multi-threading

Illustrates race conditions in multi-threaded code.

Uses lock to prevent race conditions.

  1. Simulate and Resolve a Deadlock

Simulates a deadlock scenario with two threads.

Resolves deadlock using Monitor.TryEnter.

  1. Log with System.Diagnostics.Trace

Implements logging to console and file using Trace.

Configures TextWriterTraceListener.

  1. Sanitize Input and Prevent XSS

Simulates user input form.

Sanitizes input using HTML encoding to prevent XSS attacks.

  1. Perform CRUD Operations using ADO.NET

Connects to SQL Server using SqlConnection.

Performs Create, Read, Update, Delete operations on Employees table.


Requirements

.NET 6 or later (some programs use C# 9 or 12 features)

SQL Server for program 30

Visual Studio or any C# compatible IDE


How to Use

  1. Clone the repository.

  2. Open the solution or individual .cs files in your IDE.

  3. Build and run the program you want to test.

  4. Modify the code to experiment with features and concepts.


Author Saritha Chowdary

About

This repository contains beginner-to-intermediate level exercises designed to strengthen your understanding of C# programming and ADO.NET. It covers setting up the development environment, exploring value vs reference types, working with C# 12 primary constructors, and demonstrating type inference using var and new().

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages