C# Programming Corner
Watch latest articles from C#
-
What's New in C# 13?
C# 13 introduces versatile features like enhanced `params` collections, scoped locking, and partial properties, boosting code flexibility, performance, and developer productivity for high-quality application development. -
How to Read and Write JSON Files in C#
JSON is a common data format used in APIs, configuration files, and data exchange. Learn to handle JSON in C# using `System.Text.Json`. This article covers creating data models, writing to and reading from JSON files, with practical code examples for efficient JSON management. -
Sorting with IComparable in C#
Learn how to implement the IComparable interface in C# to customize sorting behavior for objects. Explore sorting techniques, comparisons, and examples to efficiently order data in collections like lists and arrays. -
Testing API Endpoints Using C# and Swagger
Learn how to test API endpoints effectively using C# and Swagger. This guide covers setting up Swagger for API documentation, configuring C# for testing endpoints, and automating tests to ensure reliable web services. -
Understanding IEnumerable In C#
IEnumerable in C# is an interface that defines a standard way to iterate over a collection of objects. The IEnumerable interface in C# provides a standard, efficient way to iterate over collections using foreach, enabling cleaner, more readable code, and LINQ integration. -
Converting HTML to PDF or Image in C# Using wkhtmltopdf Part 2 - Header & Footer
In this tutorial, learn how to convert HTML to PDF or image in C# using wkhtmltopdf. This part covers adding and customizing headers and footers in your generated PDFs, enhancing document structure and appearance. -
Converting HTML to PDF or Image in C# Using wkhtmltopdf
This guide explains generating PDFs and images from HTML using wkhtmltopdf in C#. With wkhtmltopdf's Webkit-based engine, convert HTML content, including complex CSS and JavaScript, into high-quality PDFs or images. -
How to Store Temporary Information in Table Like Format in C#?
In this article, we will learn how to manipulate and manage in-memory data effectively, allowing for quick access and modifications while maintaining a structured format for your applications. -
Array to Text File: Detailed Overview of ArrayIOExtensionsLib Class
This article provides a comprehensive overview of the ArrayIOExtensionsLib class, detailing its functionality for converting arrays to text files in C#. We explore its key features, methods, and practical applications, including data serialization and file management techniques. -
An in-depth Look at Advanced Pattern Matching in C# 12
With Ziggy Rafiq, learn how to leverage advanced pattern matching features in C# 12, including the new let pattern and enhanced recursive patterns. -
Using Span<T> To Improve Performance Of C# Code
To enhance application performance, reducing IO calls and utilizing stack allocation is crucial. Leveraging value types and the Span<T> structure in C# allows efficient memory management and improved speed. -
Encapsulation vs Abstraction in C#
Encapsulation and abstraction are fundamental concepts in C# and object-oriented programming. Encapsulation refers to the bundling of data and methods that operate on that data within a class, promoting data hiding and security. -
Using Attributes and Metadata in C# 12
Ziggy Rafiq demonstrates how to use attributes and metadata in C# 12 including improvements in parameter types, reflection capabilities, and best practices for maintaining self-documenting code. -
Implicit vs Explicit Interface Implementations
This article explores the differences between implicit and explicit interface implementation in C#. It explains how to implement an interface in two ways using classes, highlighting the accessibility of methods. -
What is Inline Arrays in C# 12
C# 12 unveils a hidden gem - inline arrays. This article delves into these performance powerhouses, showcasing how they boost speed, simplify memory management, and enhance type safety. Discover their functionalities and practical applications in diverse scenarios like geometric operations. -
How to Compare Two Objects in C#
In this article, we’ll walk through how to create a generic method that can compare the objects of any class, even those with nested collections. We’ll break it down step by step so you can implement this in your projects effortlessly. -
Delete the Element from the Binary Tree Using C#
Learn how to efficiently delete an element from a binary tree using C#. This guide covers the complete process of node deletion, including leaf nodes, nodes with one or two children, and root node removal. -
Fibonacci Series : Recursion, Memoization, and Optimal Approach
The Fibonacci series is a mathematical sequence starting with 0 and 1, where each subsequent number is the sum of the previous two. This article explores three methods to compute Fibonacci numbers in C#: recursion, memoization, and an optimal iterative approach. -
Find And Replace Text In Word Document Using C#
Learn how to efficiently find and replace text in a Word document using C#. This guide covers essential concepts such as Microsoft Word automation, leveraging the Word Interop library, and implementing simple code examples. -
Collections in C#
This article describes Collections in C#. A collection is a way to create and manage groups of related objects. The group of objects can grow and shrink dynamically depending on the requirements in the collection. -
Palindrome Check: Normalize Strings in C#
Learn essential string manipulation techniques, including whitespace removal, case insensitivity, and character comparison. We’ll provide clear code examples and algorithms to efficiently determine if a given string reads the same forwards and backwards, enhancing your C# programming skills. -
REPR Pattern - For C# Developers
Discover the REPR Pattern, a powerful design technique tailored for C# developers. Learn how this pattern can simplify code structure, improve maintainability, and optimize performance in C# applications. -
How Func Delegates Work in LINQ
In this article, we explore how Func delegates operate within LINQ (Language Integrated Query) in C#. Func delegates enable concise and powerful data manipulation by allowing developers to pass methods as parameters. -
Understanding Callbacks with Func and Action Delegates
This article explains how to use Func and Action delegates in C# to implement callbacks, providing flexible and reusable code. It includes practical examples for both returning and non-returning methods. -
How C# Generics is different from Java Generics
In this article, we explore the distinctive features of C# generics and how they enhance programming efficiency. We compare generics with non-generic types, focusing on benefits like type safety, code reusability, and performance optimization. -
Understanding Key Concepts in Domain-Driven Design
In this article, we will explore how these concepts drive effective software modeling, ensuring alignment between the business domain and your codebase. -
C#.NET - Access OAuth REST Web API Method
C#.NET applications can access OAuth-protected REST APIs. You'll obtain an access token through OAuth flow (often via a separate request) and include it in the authorization header of your HttpClient calls. -
Using C# 12 with Clean Code Practices
Learn how to write cleaner, more maintainable code with C# 12 features such as primary constructors and improved pattern matching. This article explores practical examples and tips for applying clean code practices with C# 12. -
C# Code To Overcome "The Process Cannot Access The File XYZ Because It Is Being Used By Another Process" Error
This guide provides practical C# code solutions for handling file access issues, including techniques for managing file locks and ensuring smooth file operations without interruptions. -
Why To Use C# And When To Prefer Other Languages
This blog explores the choice between programming languages like C#, C++, and Java, focusing on productivity, ease of use, and project requirements. It emphasizes the importance of selecting the right language for the task, the advantages of using frameworks like .NET, and considerations for team capabilities and project architecture. -
Cleaning the Resources: Finalize vs Dispose
This article explores the concepts of Destructor and Dispose in C#. It illustrates the object's lifecycle, highlighting how constructors allocate memory and destructors clean up. The role of the Garbage Collector is discussed, emphasizing the importance of implementing IDisposable for managing unmanaged resources efficiently. -
Why We Should Prefer To Use Dispose Method Than Finalize Method
This article explores the benefits of Dispose for efficient resource cleanup, improved performance, and reliable memory management in C#. Discover best practices for handling managed and unmanaged resources effectively. -
An overview of the Task Parallel Library (TPL) in C#
The Task Parallel Library (TPL) is a collection of public types and APIs within the .NET framework that facilitates the integration of parallelism and concurrency into applications. -
POCO to Dictionary Conversion Techniques in C#
This article explores five methods for converting a C# POCO to a dictionary using reflection, LINQ, JSON libraries, and ExpandoObject, comparing their performance through Benchmark.NET to find the best approach. -
What is Indexer in C#?
An indexer in C# allows objects to be indexed like arrays, enabling access to elements using an index. It’s defined with this keyword and can be used to encapsulate data access in a class or struct. Indexers enhance the flexibility and readability of code by simplifying element retrieval and storage. -
Action And Func Delegates In C#
In C#, Action, and Func are generic delegates used to handle methods. Action is used for methods that don't return a value, while Func returns a value. Action<int> executes a method with an integer parameter without returning a result. Func<int, int> takes an integer, performs an operation, and returns the result. -
Detailed use of Action Delegate in C#
In C#, the Action delegate represents a method that does not return a value and can accept up to 16 parameters. It's useful for passing methods as arguments, callbacks, and event handling. It supports lambda expressions and anonymous methods, making code more concise. Unlike Func<T>, Action always returns void. -
Explain Switch Case Uses in C#
In C#, the switch statement serves as a control structure that enables the execution of distinct code blocks based on the value of a variable. It is frequently utilized when there is a need to compare a variable with multiple constant values and to carry out various actions according to the outcome. -
Exaplain Copy Constructor in C#
A copy constructor in C# allows creating a new object by copying an existing object. It duplicates the values of properties and fields from the original object. This method is useful for creating independent object copies, enhancing code readability, and managing object duplication efficiently. -
Working With FTP Using C#
Learn how to work with FTP (File Transfer Protocol) using C# in this comprehensive guide. Explore how to connect to FTP servers, upload and download files, and manage file transfers programmatically. -
Serialization And Deserialization In C# Using Protobuf-net.dll
This article describes how to implement serialization and deserialization using Protobuf-net.dll. This article explores Protobuf-net, a .NET library for efficient serialization and deserialization using Google's Protocol Buffers. -
A Guide to Using the Decorator Pattern in Your C# Code
In this article, we will learn how to implement this pattern in your C# code, improve code reusability, and follow best practices for more maintainable and flexible software design. -
Using Factory Patterns in C# 12 to simplify A/B testing
Find out how Ziggy Rafiq simplifies A/B testing with feature toggles in C# 12 by using Factory and Abstract Factory design patterns. -
Optimizing Searching Algorithms in C# and Reducing Complexities
This article explores the implementation of 10 common searching algorithms in C#, detailing their use cases, workings, and complexities. From simple linear searches to more complex algorithms like Binary Search, Jump Search, and KMP, this guide provides code examples and insights into optimizing search efficiency. -
C# 12 Design Patterns: Factory and Abstract Factory
By Ziggy Rafiq, discover how Factory and Abstract Factory design patterns simplify the creation of complex objects in C# 12. -
Understanding of Domain Driven Design (DDD)
Domain-driven design is a software development approach that closely aligns software models with business needs. It focuses on key concepts like Entities, Value Objects, Aggregates, and Aggregate Roots to ensure consistency, integrity, and scalability in complex systems by structuring code around the business domain. -
Interface Re-implementation in C#
This guide covers the principles of object-oriented programming, including inheritance and polymorphism, and demonstrates practical techniques for effective interface re-implementation and code refactoring. -
Crafting Efficient and Maintainable C# Code
This guide explores essential C# best practices for robust, maintainable code. It covers using meaningful variable names, following naming conventions, handling null values, and using var judiciously. -
Abstract Factory Design Pattern in .NET Core C# 12
In this detailed article by Ziggy Rafiq, you will learn how to implement key components like AbstractFactory, ConcreteFactory, AbstractProduct, and ConcreteProduct in .NET Core with C# 12. By leveraging the modern features of C# 12 and .NET Core, this pattern enhances flexibility and scalability in software development. -
Resolving Race Conditions and Critical Sections in C#
A race condition in C# occurs when multiple threads access shared data simultaneously without proper synchronization, leading to unpredictable and incorrect results. This tutorial covers how to identify and resolve race conditions and critical section issues in multi-threaded .NET applications using the lock keyword. -
Default Implementation in C# Interfaces
This article details creating a `StringUtils` utility class in Java to centralize common string operations. It covers methods for checking if a string is alphanumeric with underscores or consists solely of letters, enhancing code organization and reusability. -
How to Create a Custom Message Box in Windows Form Application
Learn how to create a custom message box in a Windows Forms application using C#. This step-by-step guide covers everything from designing the message box to implementing it in your WinForms project. -
Understanding Dependency Inversion Principle (DIP) with C#
This guide explains how DIP enhances software design by decoupling high-level and low-level modules, promoting flexibility and maintainability. Understand its implementation using Dependency Injection and best practices in C#. -
Basics Of C#
This article explains C# basics with C# code examples including C# data types, class, objects, properties, and methods. You'll also learn basic OOP concepts such as overloading, polymorphism, abstraction, and interfaces. The article also covers common iteration statements including for, while, do while, and foreach. -
Difference between lock(this) and lock(privateObj) in C#
In multi-threaded C# programming, the lock statement ensures that critical code sections are accessed by only one thread at a time. While lock(this) locks on the current instance, it can expose your object to external locking, leading to potential deadlocks. -
Understanding the Flag Enums in C#
The [Flags] attribute in C# allows an enum to represent a combination of values using bitwise operations. This is useful when an enum needs to store multiple values simultaneously. By applying [Flags], enum members can be combined using bitwise OR, and specific values can be checked with bitwise AND or HasFlag. -
Understanding the Interface Segregation Principle (ISP) with C#
Explore the Interface Segregation Principle (ISP) from SOLID design principles to ensure code flexibility and maintainability. ISP advocates for breaking down large, unwieldy interfaces into smaller, client-specific ones, reducing unnecessary dependencies. Learn how to apply this principle with practical examples in C#. -
Code Examples for .NET 8 Features with C# 12
An in-depth look at performance enhancements, language improvements, and new libraries in this comprehensive article by Ziggy Rafiq. -
Detailed use of Tuples and Value Tuples in C#
This guide explores the detailed use of Tuples and ValueTuples in C#. It covers their differences, how to create and manipulate them, and practical examples for implementing them in real-world applications. -
Create QR Code Report Using RDLC Report With Preview
In this article we can learn how to make our own QR code. Make a QR report using RDLC reports with preview condition. -
Understanding the Record in C#
Learn how records differ from classes, their advantages in creating immutable types, and how they enhance object initialization, equality checks, and more in .NET applications. -
Understanding the Liskov Substitution Principle (LSP) with C#
The Liskov Substitution Principle (LSP) ensures that objects of a base class can be replaced with objects of a derived class without altering program correctness. This principle, part of SOLID design, promotes reliable and maintainable code by maintaining consistent behavior across class hierarchies. -
Learn Server-Sent Events in C# .NET
Server-Sent Events (SSE) in C# .NET enable real-time, one-way communication from server to client over HTTP, ideal for live updates like notifications or data streaming. Unlike WebSockets, SSE is simpler, requiring only server-side implementation. -
Iterations and Improving Code Quality with C# yield return
This article explores how the yield return statement in C# can simplify iteration logic and enhance code quality. By allowing deferred execution and creating custom iterators, developers can write more efficient and readable code. -
Understanding the Open/Closed Principle (OCP) with C#
The Open/Closed Principle (OCP) states that software entities should be open for extension but closed for modification. This principle helps in creating flexible and maintainable code by allowing new functionality to be added without altering existing code. -
Tortoise SVN Automation Using C#
In this article, we will look into automation of Tortoise SVN activities like checkout, delete, rename on a SVN repository using C# in a console application. -
Leveraging Records for Data Transfer Objects (DTOs) in C# .NET
This article explores how to leverage C# records for implementing Data Transfer Objects (DTOs) in .NET. It delves into the benefits of using records for immutable data structures, enhancing code readability, and reducing boilerplate. -
Func, Action And Local Function In C# 7
This article covers using Func, Action, and local functions in C# 7. It explains how Func returns a value, Action does not, and how local functions can be defined within other methods. Examples include checking for prime numbers, printing the Fibonacci series, and calculating factorials. -
Transitioning from Switch Statements To Switch Expressions in C#
Explore how to modernize your C# code by transitioning from traditional switch statements to the more concise and powerful switch expressions introduced in C# 8.0. -
Difference Between Tuples vs ValueTuples in C#
In this article, we will discover practical use cases for each, and understand when to choose one over the other in your C# applications to enhance code efficiency and readability. -
Validating User Input Using Regular Expression With C#
In software development, validating user input is crucial to prevent errors and security issues. Regular expressions (regex) are used to validate fields such as email, zip codes, and phone numbers. This C# example demonstrates using regex for validation in a Windows Forms app, ensuring data accuracy and security. -
How To Enable C# 7.1 Version To My Projects
To update your project to C# 7.1, you can use one of three methods: 1) Through Visual Studio Project Properties by selecting C# 7.1 in the Build menu. 2) By editing the csproj file and setting <LangVersion>7.1</LangVersion>. 3) Using the Lightbulb Box feature to automatically upgrade all projects. -
Understanding Multithreading with the Thread Class in C#
Learn how to implement multithreading in C# using the Thread class. This guide covers creating and managing threads, passing parameters, handling exceptions, and using Task for simplified parallelism. Improve your application's performance by understanding these core concepts and techniques. -
Multithreading in C# Task Creation Using Loop
This article introduces multithreading in C# using the Task class from the Task Parallel Library (TPL). It explains creating and executing tasks serially within a loop, ensuring tasks are completed sequentially. An example demonstrates task creation and simulating work with delays. -
Exploring ValueTask in C#
xploring ValueTask in C#" delves into the intricacies of the ValueTask type introduced in C#. It compares ValueTask with Task, highlighting performance benefits and appropriate use cases. -
How to Get Only Letters from a String in C#?
Learn how to extract only the letters from a string in C# using various methods. This guide covers techniques such as using regular expressions, string manipulation methods, and LINQ to filter out non-letter characters. -
Async/Await: Beyond the Basics
Error handling in async code involves using try-catch blocks to manage exceptions, ensuring smooth operation. Task chaining, like a relay race, connects tasks so the result of one task feeds into the next. -
Intra-process vs Inter-process Synchronization in C#
In C#, intra-process synchronization involves managing concurrency within a single process using tools like lock, Mutex, and Semaphore. Inter-process synchronization deals with coordination between separate processes using similar mechanisms. -
Why We Should Avoid Using await in C# Loops
Avoid using `await` inside C# loops as it causes sequential execution and resource contention, leading to poor performance. Instead, use alternatives like `Task.WhenAll`, `Parallel.ForEachAsync`, or `SemaphoreSlim` to handle asynchronous operations concurrently and efficiently. -
Getting Started With Unit Testing Using C# And xUnit
Unit Testing in ASP.NET Core involves testing individual components or methods to ensure they work as intended. By creating test cases for small functionalities, developers can catch bugs early, improve code quality, and follow TDD principles. Tools like xUnit are used to automate and organize these tests efficiently. -
Mask an Aadhar Number into Blocks of 4 Digits Each
This C# code demonstrates how to mask sensitive numbers, like Aadhar or account numbers. It validates input length, uses StringBuilder to format Aadhar numbers with spaces, and shows account number masking via substring, regex, and string formatting. -
C# Access Modifiers
This article will discuss the C# Access Modifiers -
Intermediate Code Optimizations in C#
Intermediate code optimization in C# improves performance by refining Intermediate Language (IL) code. Techniques like inlining, loop optimizations, dead code elimination, and constant folding enhance runtime efficiency and reduce overhead. -
How to Use JWSHMAC in ASP.NET Web Application
Learn how to implement JWSHMAC in an ASP.NET web application to secure JSON data using HMAC. This guide covers installing the JWT NuGet package, creating a JWT helper class for token generation and validation, and configuring authentication middleware. -
Understanding Iterators in C#
In this article, we will Understand key concepts, such as iterator methods and custom iteration patterns, and enhance your C# programming skills with practical examples and tips. -
Understanding of LINQ
LINQ (Language Integrated Query) is a powerful feature in .NET that allows developers to write SQL-like queries directly in C# or VB.NET. It supports querying collections, XML, databases, and more, using a syntax that integrates seamlessly with the language. -
XOR Operator in C# and Its Properties
The XOR operator (`^`) in C# is essential for bitwise operations, comparing binary values bit by bit. It is used for tasks like encryption, error detection, and data manipulation. -
Understanding Sealed Classes in C#
Sealed classes in C# are a vital concept in object-oriented programming, preventing other classes from inheriting them. This ensures a secure and stable class hierarchy by stopping further extension. -
Detailed Explanation of Builder Design Pattern in C#
The Builder design pattern is a creational pattern used to construct complex objects step by step. It separates the object's construction from its representation, allowing for varied configurations and ensuring immutability. -
Encapsulation, Inheritance, and Polymorphism in C#
In this article, we will learn how to encapsulate data for security, leverage inheritance for code reuse, and implement polymorphism to create flexible and scalable applications. -
How to Start a Project in C#?
This article guides you through starting a C# project, including setting up Visual Studio or Visual Studio Code, creating a new project, and configuring essential features like dependency injection, configuration management, and logging. -
Wrapper Class vs. Object Composition with UseCase
Explore Wrapper Classes and Object Composition in object-oriented programming. Learn how wrappers adapt interfaces and enhance functionality without altering code, ideal for legacy systems. -
String.Join vs Loops in C#
String.Join vs. Loops: C#" explores the efficiency and performance differences between using String.Join and traditional looping methods for string concatenation in C#. -
Discard Variable in C# .NET
The discard variable (_), introduced in C# 7.0, allows developers to ignore values intentionally. It enhances code clarity by signaling unused data in tuples, pattern matching, out parameters, and LINQ queries, promoting cleaner, more efficient, and maintainable programming in .NET applications. -
C# Abstract Class with Examples
Explore the fundamentals of C# abstract classes through clear examples and detailed explanations. Learn how abstract classes facilitate code reusability and polymorphism in object-oriented programming, with practical demonstrations of their usage and implementation in C#. -
Differences Between IEnumerable and IQueryable in C#
Explore the nuances between IEnumerable and IQueryable in C#. Understand how these interfaces differ in data retrieval and manipulation, with a focus on performance implications and suitable use cases. -
Understanding JSON Web Tokens (JWT)
JSON Web Tokens (JWT) are a popular method for securely transmitting information between parties as a JSON object. This article explores the fundamentals of JWT, including its structure, encoding, and common use cases in authentication and authorization. -
Polymorphism Concept OOPS
Polymorphism in C# involves method overloading (multiple methods with the same name but different parameters), method overriding (subclass provides specific implementation of a method in the parent class), and method hiding (subclass hides a method from the parent class). -
Left and Right Shift operators in C#
This article delves into the intricacies of left and right shift operators in C#. You'll learn how these bitwise operators work, their syntax, and practical applications. -
Exploring Advanced Error Handling Techniques in C#
Error handling is a crucial aspect of software development, ensuring that applications can gracefully handle unexpected situations and maintain robust functionality. In C#, error handling is typically managed using exceptions.