Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Shell Sort program in C#
Shell Sort is an optimized version of insertion sort that allows the exchange of items that are far apart in the array. It starts with a large gap between compared elements and progressively reduces this gap until it becomes 1. This algorithm was developed by Donald Shell in 1959, hence the name. Unlike insertion sort which compares adjacent elements, Shell Sort compares elements separated by a gap. This reduces the number of shifts needed and makes the algorithm more efficient for larger datasets. How Shell Sort Works Shell Sort works by dividing the array into smaller sub-arrays ...
Read MoreType.GetArrayRank() Method in C#
The Type.GetArrayRank() method in C# returns the number of dimensions in an array type. This method is useful when working with multidimensional arrays and you need to determine how many dimensions the array has at runtime. The method works only with array types. If called on a non-array type, it throws an ArgumentException. Syntax Following is the syntax for the GetArrayRank() method − public virtual int GetArrayRank(); Return Value The method returns an int representing the number of dimensions in the array. For example, a single-dimensional array returns 1, a two-dimensional array ...
Read MoreNaming Conventions in C#
Naming conventions in C# help maintain code readability and consistency across projects. Following standardized naming patterns makes your code more professional and easier to understand for other developers. Class Naming Conventions A class definition starts with the class keyword followed by the class name, enclosed by curly braces. The following conventions apply to class names. Pascal Casing Class names should use PascalCasing, where the first letter of each word is capitalized − public class EmployeeDetails { } public class BankAccount { } public class CustomerOrderHistory { } Noun or Noun Phrases ...
Read MoreDeadlock and Starvation in C#
Deadlock occurs when two or more threads are permanently blocked, each waiting for a resource held by another thread. This creates a circular dependency where no thread can proceed, making it a critical problem in multithreaded applications. Starvation happens when a thread is indefinitely denied access to resources it needs, typically because other threads with higher priority continuously monopolize those resources. Understanding Deadlock A deadlock situation arises when threads hold locks and wait for other locks in a circular chain. The classic scenario involves two threads and two resources − Thread One Thread ...
Read MoreRemove duplicates from a List in C#
Removing duplicates from a List in C# is a common task when working with collections. There are several approaches to accomplish this, with Distinct() being the most straightforward method. The Distinct() method uses LINQ to filter out duplicate elements based on their default equality comparison. Syntax Following is the syntax for using Distinct() to remove duplicates − List uniqueList = originalList.Distinct().ToList(); For custom equality comparison − List uniqueList = originalList.Distinct(comparer).ToList(); Using Distinct() Method The Distinct() method from LINQ is the simplest way to remove duplicates from a list. It ...
Read MoreClear a Linked List in C#
The Clear() method in C# is used to remove all nodes from a LinkedList. This method provides an efficient way to empty the entire linked list in a single operation, resetting the Count property to zero. Syntax Following is the syntax for the Clear() − linkedList.Clear(); Parameters The Clear() method takes no parameters. Return Value The Clear() method does not return any value. It is a void method that modifies the linked list in-place. LinkedList Clear() Operation Before Clear(): ...
Read MoreWhat are all the possible C# array initialization syntaxes?
C# provides multiple ways to initialize arrays, giving you flexibility in how you declare and populate arrays with values. Each syntax has its specific use cases depending on whether you know the array size in advance or want to provide initial values immediately. Array Initialization Syntax Options Explicit Size with Values You can specify the array size explicitly along with initial values − int[] marks = new int[5] { 99, 98, 92, 97, 95 }; Implicit Size with Values The array size can be inferred from the number of elements provided − ...
Read MoreHow to declare member function in C# interface?
To declare member functions in C# interfaces, you define method signatures without implementations. The implementing class must provide the actual method bodies using the public access modifier. Syntax Following is the syntax for declaring member functions in an interface − public interface InterfaceName { ReturnType MethodName(parameters); void AnotherMethod(); } The implementing class must provide implementations for all interface methods − public class ClassName : InterfaceName { public ReturnType MethodName(parameters) { // implementation } ...
Read MoreWay to increment a character in C#
In C#, you can increment a character by using the increment operator ++. When you increment a character, it moves to the next character in the ASCII table sequence. Syntax Following is the syntax for incrementing a character − char ch = 'K'; ch++; // moves to next ASCII character You can also use the compound assignment operator − ch += 1; // equivalent to ch++ How It Works Characters in C# are stored as numeric values based on their ASCII or Unicode code points. When you ...
Read MoreNull List in C#
A null list in C# refers to a List reference that points to nothing instead of an actual List object. This is different from an empty list, which is an initialized List with zero elements. Understanding null lists is crucial for avoiding NullReferenceException errors in your applications. Syntax To declare a null list − List listName = null; To check if a list is null − if (listName == null) { // handle null case } Creating and Checking Null Lists When you declare a List ...
Read More