Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 16 of 196

How to write retry logic in C#?

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

Retry logic is implemented to handle transient failures that may resolve themselves after a brief delay. This pattern is essential when working with network operations, database connections, or external APIs that may temporarily fail due to network issues, service overload, or temporary unavailability. It's important to log all connectivity failures that cause a retry so that underlying problems with the application, services, or resources can be identified. Implement retry logic only where you have the full context of a failing operation and when the operation is idempotent (safe to repeat). Syntax Following is the basic syntax for ...

Read More

What is the difference between IEnumerable and IQueryable in C#?

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

The IEnumerable and IQueryable interfaces are both used for querying collections in C#, but they differ significantly in how they execute queries and handle data. Understanding these differences is crucial for writing efficient database queries and managing memory usage. Key Differences Feature IEnumerable IQueryable Namespace System.Collections System.Linq Query Execution In-memory (client-side) Server-side (database) Lazy Loading Not supported Supported Extension Methods Use functional objects Use expression trees Best For In-memory collections Database queries Syntax Following is the syntax for ...

Read More

How to implement interface in anonymous class in C#?

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

No, anonymous types cannot implement an interface. We need to create your own type. Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to explicitly define a type first. The type name is generated by the compiler and is not available at the source code level. The type of each property is inferred by the compiler. Syntax Following is the syntax for creating anonymous types − var anonymousObject = new { Property1 = value1, Property2 = value2 }; Why Anonymous Types Cannot Implement ...

Read More

What is bin and obj folder in C#?

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

Whenever we write a C# code and build or run the solution, it generates 2 folders − bin folder obj folder These folders contain compiled code at different stages of the compilation process. Understanding the difference between them is crucial for C# developers working with build systems and deployment. Why Two Folders? The compilation process in C# goes through multiple stages, which is why we have separate folders for different outputs − Compiling − Individual source files are compiled into intermediate objects Linking − All compiled objects are linked together into the ...

Read More

What is difference between using if/else and switch-case in C#?

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

The switch statement and if-else statements are both selection statements in C# used for decision-making, but they serve different purposes and have distinct performance characteristics. The switch statement chooses a single section to execute from a list of candidates based on pattern matching, while if-else provides conditional branching based on boolean expressions. Syntax Following is the syntax for a switch statement − switch (expression) { case value1: // code block break; case ...

Read More

What is #if DEBUG and How to use it in C#?

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

In Visual Studio, Debug mode and Release mode are different configurations for building your .NET project. The #if DEBUG directive is a preprocessor conditional compilation directive that allows you to include or exclude code blocks based on whether the DEBUG symbol is defined. The Debug mode does not optimize the binary it produces because the relationship between source code and generated instructions is more complex. This allows breakpoints to be set accurately and allows programmers to step through the code one line at a time. The Debug configuration compiles with full symbolic debug information, while the Release configuration has ...

Read More

What are the improvements in Out Parameter in C# 7.0?

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

C# 7.0 introduced significant improvements to out parameters that make code more concise and readable. The major enhancement is the ability to declare out variables inline as arguments to the method where they're used, eliminating the need for separate variable declarations. Syntax Prior to C# 7.0, out variables had to be declared before use − int result; if (int.TryParse("123", out result)) { // use result } C# 7.0 allows inline declaration − if (int.TryParse("123", out int result)) { // use result immediately } Key ...

Read More

How to subscribe to an Event in C# and can we have multiple subscribers to one Event in a C#?

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

Events enable a class or object to notify other classes or objects when something of interest occurs. The class that raises the event is called the publisher and the classes that handle the event are called subscribers. An event can have multiple subscribers, and a subscriber can handle multiple events from multiple publishers. Events that have no subscribers are never raised. The publisher determines when an event is raised; the subscribers determine what action is taken in response to the event. Syntax Following is the syntax for declaring an event using EventHandler − public event ...

Read More

What are Deconstructors in C# 7.0?

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

Deconstructors in C# 7.0 are methods that allow you to extract multiple values from an object into separate variables in a single assignment. They enable tuple-like deconstruction of custom types, making it easier to work with objects that contain multiple related values. A deconstructor is defined using the Deconstruct method name with out parameters. When you use tuple syntax on the left side of an assignment, C# automatically calls the appropriate Deconstruct method. Syntax Following is the syntax for defining a deconstructor method − public void Deconstruct(out Type1 param1, out Type2 param2, out Type3 param3) ...

Read More

How to use order by, group by in c#?

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

The OrderBy and GroupBy operators are essential LINQ methods in C# that allow you to sort and organize data collections. OrderBy sorts sequences in ascending order, while GroupBy organizes flat sequences into groups based on a specified key. These operators are particularly useful when working with collections of objects that need to be organized or sorted for better data presentation and analysis. Syntax Following is the syntax for OrderBy operator − var result = collection.OrderBy(x => x.PropertyName); var resultDesc = collection.OrderByDescending(x => x.PropertyName); Following is the syntax for GroupBy operator − ...

Read More
Showing 151–160 of 1,958 articles
« Prev 1 14 15 16 17 18 196 Next »
Advertisements