Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 19 of 196

How to add custom message handlers to the pipeline in Asp.Net webAPI C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 695 Views

To create a custom Server-Side HTTP Message Handler in ASP.NET Web API, we need to create a class that must be derived from the System.Net.Http.DelegatingHandler. Message handlers allow you to intercept HTTP requests and responses, enabling cross-cutting concerns like logging, authentication, caching, or request modification. How Message Handlers Work Message handlers form a pipeline where each handler can process the request before passing it to the next handler, and process the response on its way back. This provides a powerful mechanism for implementing middleware-like functionality in Web API. Message Handler Pipeline ...

Read More

How to return a string repeated N number of times in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 5K+ Views

There are several ways to repeat a string or character N number of times in C#. This article covers three effective approaches: using the string constructor for characters, string.Concat with Enumerable.Repeat, and StringBuilder for more complex scenarios. Using String Constructor for Characters The simplest way to repeat a single character is using the string constructor that takes a character and a count − string repeatedString = new string(character, count); Example using System; namespace DemoApplication { public class Program { ...

Read More

What are some of the fastest way to read a text file line by line using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

There are several fast and efficient ways to read a text file line by line in C#. The most commonly used methods are StreamReader.ReadLine, File.ReadLines, and File.ReadAllLines. Each method has its own advantages depending on the use case and file size. Using StreamReader.ReadLine StreamReader is the most memory-efficient approach for reading large files since it processes one line at a time without loading the entire file into memory. This method is ideal for processing very large files where memory usage is a concern. Example using System; using System.IO; using System.Text; namespace DemoApplication { ...

Read More

How to flatten a list using LINQ C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 7K+ Views

Flattening a list means converting a List to List. For example, converting a List containing multiple integer lists into a single List with all elements combined. The SelectMany operator in LINQ is used to project each element of a sequence to an IEnumerable and then flatten the resulting sequences into one sequence. It combines records from a sequence of results and converts them into a single flattened result. Flattening Process [1, 2] [3, 4] ...

Read More

How to install a windows service using windows command prompt in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 3K+ Views

A Windows Service is a long-running application that runs in the background without a user interface. In C#, you can create a Windows Service application and install it using the command prompt with the InstallUtil.exe utility. This tutorial demonstrates creating a simple Windows Service that logs messages to a text file and installing it through the command line. Creating the Windows Service Application Step 1: Create New Windows Service Project Create a new Windows Service application in Visual Studio. This provides the basic template with a Service1 class that inherits from ServiceBase. Step ...

Read More

What is the difference between | and || operators in c#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 963 Views

The || is called logical OR operator and | is called bitwise logical OR operator. The key difference between them lies in how they evaluate expressions and when they stop execution. Syntax Both operators have similar syntax − bool_exp1 || bool_exp2 // Logical OR (short-circuit) bool_exp1 | bool_exp2 // Bitwise OR (always evaluates both) Key Differences Logical OR (||) Bitwise OR (|) Short-circuit evaluation - stops if first expression is true Always evaluates both expressions More efficient for boolean operations Less ...

Read More

How can we get the client's IP address in ASP.NET MVC C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 3K+ Views

Every machine on a network has a unique identifier called an IP address. Just as you would address a letter to send in the mail, computers use this unique identifier to send data to specific computers on a network. In ASP.NET MVC applications, you often need to retrieve the client's IP address for logging, security, or analytics purposes. There are several methods to obtain a client's IP address in ASP.NET MVC C#. Each method has its own advantages and use cases depending on your application's architecture and hosting environment. Using HttpRequest.UserHostAddress Property The UserHostAddress property is the ...

Read More

How to set a property having different datatype with a string value using reflection in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

Reflection in C# allows managed code to examine and manipulate its own metadata, including types, properties, and methods at runtime. This powerful feature enables you to dynamically work with objects without knowing their types at compile time. A common scenario is when you need to set a property of one data type (like double) using a string value at runtime. This can be accomplished using reflection combined with type conversion. Syntax Following is the syntax for getting property information using reflection − PropertyInfo propertyInfo = obj.GetType().GetProperty("PropertyName"); Following is the syntax for setting a ...

Read More

How do we specify MIME type in Asp.Net WebAPI C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 2K+ Views

A media type, also called a MIME type, identifies the format of a piece of data. In HTTP, media types describe the format of the message body. A media type consists of two strings, a type and a subtype. For example − text/html image/png application/json When an HTTP message contains an entity-body, the Content-Type header specifies the format of the message body. This tells the receiver how to parse the contents of the message body. When the client sends a request message, it can include an Accept header. The Accept header tells the server which ...

Read More

How to run an external application through a C# application?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 5K+ Views

An external application can be run from a C# application using the Process class. A process is a program that is running on your computer. This can be anything from a small background task, such as a spell-checker or system events handler, to a full-blown application like Notepad. Each process provides the resources needed to execute a program and is started with a single thread, known as the primary thread. Processes are heavily dependent on system resources, while threads require minimal resources. The Process class is present in the System.Diagnostics namespace. Syntax Following is the basic syntax ...

Read More
Showing 181–190 of 1,958 articles
« Prev 1 17 18 19 20 21 196 Next »
Advertisements