Server Side Programming Articles

Page 843 of 2109

Const vs Static vs Readonly in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 1K+ Views

The const, static, and readonly keywords in C# serve different purposes for declaring fields and members. Understanding their differences is crucial for choosing the right approach based on your specific needs. Const Constant fields are compile-time constants that cannot be modified after declaration. They must be assigned a value at the time of declaration and are implicitly static. const int a = 5; Example using System; class Constants { public const int MaxValue = 100; public const string AppName = "MyApp"; public ...

Read More

Call a method Asynchronously in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 323 Views

Asynchronous programming in C# is an efficient approach for handling operations that may be blocked or delayed. In synchronous processing, if an operation is blocked, the entire application waits, causing it to become unresponsive and take longer to complete tasks. Using the asynchronous approach, applications can continue executing other tasks while waiting for blocked operations to complete. This is especially important in GUI applications where blocking the main thread causes the interface to freeze. The Problem with Synchronous Code In GUI applications, when synchronous operations take too long, the application shows "not responding" messages because the main ...

Read More

Dynamic Binding in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

In Dynamic binding, the compiler defers type checking until runtime instead of compile time. This allows you to work with objects whose types are determined dynamically, providing flexibility when dealing with anonymous types, COM objects, or dynamic languages. The dynamic keyword in C# enables late binding, where method calls, property access, and type conversions are resolved at runtime. This is particularly useful for returning anonymous types from methods, since anonymous type names are only visible to the compiler. Syntax Following is the syntax for declaring a dynamic variable − dynamic variableName = value; ...

Read More

Exception Propagation in C#

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

Exception propagation in C# refers to the process of how exceptions move up through the call stack when they are not handled by the current method or try-catch block. When an exception occurs, the runtime searches for an appropriate exception handler, and if none is found, the exception propagates to the calling method. How Exception Propagation Works When an exception occurs in a try block, the runtime checks the corresponding catch blocks to see if they can handle the exception. If no matching catch block is found, the exception propagates to a higher-level try block or to the ...

Read More

Dictionary Methods in C#

Samual Sam
Samual Sam
Updated on 17-Mar-2026 5K+ Views

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collections.Generic namespace and provides methods to add, remove, and search for key-value pairs efficiently. Common Dictionary Methods Method Description Add(TKey, TValue) Adds a key-value pair to the Dictionary Remove(TKey) Removes the element with the specified key Clear() Removes all keys and values from the Dictionary ContainsKey(TKey) Checks whether the specified key exists ContainsValue(TValue) Checks whether the specified value exists TryGetValue(TKey, out TValue) Safely retrieves a value ...

Read More

Delete nth element from headnode using C#

George John
George John
Updated on 17-Mar-2026 211 Views

Deleting the nth element from a linked list involves traversing to the target node and adjusting the links to bypass it. When deleting from the head position (n=1), we simply update the head reference. For other positions, we need to find the node before the target and redirect its Next pointer. Syntax Following is the basic structure for deleting the nth node − if (n == 1) { head = head.Next; return; } Node current = head; for (int i = 1; i < n - 1; ...

Read More

Debug Class vs Debugger Class in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 459 Views

The Debug class and Debugger class in C# are both part of the System.Diagnostics namespace but serve different purposes. The Debug class provides methods for conditional debugging output, while the Debugger class enables communication and interaction with debuggers attached to your application. Debug Class The Debug class is a static class that provides conditional compilation methods for debugging. It outputs information only when the DEBUG symbol is defined during compilation − public static class Debug Properties of Debug Class Property Description AutoFlush Gets or sets a ...

Read More

What is the Item property of Hashtable class in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 174 Views

The Item property of the Hashtable class in C# gets or sets the value associated with the specified key. This property uses the indexer syntax [key] and allows you to both retrieve existing values and add new key-value pairs to the hashtable. When a key does not exist in the hashtable, you can use the Item property to add it along with its value. This makes it convenient for both accessing and modifying hashtable contents. Syntax Following is the syntax for using the Item property − // Getting a value object value = hashtable[key]; ...

Read More

C# program to find maximum and minimum element in an array

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 7K+ Views

To find the maximum and minimum elements in an array in C#, we initialize both values to the first element of the array and then compare each subsequent element. This approach ensures we correctly identify the extreme values regardless of the array's content. Algorithm The algorithm follows these steps − Initialize both max and min variables to the first array element. Iterate through the array starting from the second element (index 1). Compare each element with the current max and min values. Update max and min accordingly when a larger or smaller element is found. ...

Read More

What is the scope of a private member variable of a class in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 533 Views

The scope of a private member variable in C# is limited to the class in which it is declared. Only methods and properties within the same class can directly access private members. This implements the principle of data encapsulation, which hides internal implementation details from external code. Syntax Following is the syntax for declaring private member variables − private dataType variableName; Private members can only be accessed by methods within the same class − class ClassName { private int value; public void ...

Read More
Showing 8421–8430 of 21,090 articles
« Prev 1 841 842 843 844 845 2109 Next »
Advertisements