Arjun Thakur

Arjun Thakur

749 Articles Published

Articles by Arjun Thakur

Page 5 of 75

How to determine if the string has all unique characters using C#?

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

To determine if a string has all unique characters, you need to check if any character appears more than once. This can be accomplished using several approaches in C#, from simple nested loops to more efficient data structures like HashSet. Using Nested Loop Approach The basic approach involves comparing each character with every other character in the string − using System; class Program { public static bool HasUniqueCharacters(string val) { for (int i = 0; i < val.Length - 1; i++) { ...

Read More

What is the difference between a list and an array in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 8K+ Views

An array stores a fixed-size sequential collection of elements of the same type, whereas a list is a generic collection that can dynamically resize during runtime. Understanding the differences between arrays and lists is crucial for choosing the right data structure for your C# applications. Syntax Following is the syntax for declaring and initializing an array − dataType[] arrayName = new dataType[size]; dataType[] arrayName = {value1, value2, value3}; Following is the syntax for declaring and initializing a list − List listName = new List(); List listName = new List {value1, value2, value3}; ...

Read More

Difference between C# and Visual C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 2K+ Views

C# and Visual C# are essentially the same programming language. C# is the programming language specification, while Visual C# refers to the C# development experience within Microsoft's Visual Studio IDE. Think of Visual C# as the toolset and environment for writing C# code. Microsoft Visual Studio is an Integrated Development Environment (IDE) that provides comprehensive tools for developing applications, web services, and desktop programs. When you use Visual Studio to write C# code, you're using what Microsoft calls "Visual C#" − the C# compiler, IntelliSense, debugging tools, and project templates all integrated together. Key Differences ...

Read More

Default value of StringBuilder in C#

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

The default operator in C# returns the default value for any data type. For reference types like StringBuilder, the default value is null. This is useful when you need to initialize a StringBuilder variable without creating an instance immediately. Syntax Following is the syntax for using the default operator with StringBuilder − StringBuilder variable = default(StringBuilder); In C# 7.1 and later, you can also use the simplified syntax − StringBuilder variable = default; Using default(StringBuilder) Example using System; using System.Text; public class Demo { ...

Read More

C# Program to add a node before the given node in a Linked List

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

A LinkedList in C# is a doubly-linked list that allows efficient insertion and deletion of nodes at any position. The AddBefore() method inserts a new node immediately before a specified existing node in the linked list. Syntax Following is the syntax for the AddBefore() method − public LinkedListNode AddBefore(LinkedListNode node, T value) public LinkedListNode AddBefore(LinkedListNode node, LinkedListNode newNode) Parameters node − The existing LinkedListNode before which to insert the new node. value − The value to add to the LinkedList. newNode − The new LinkedListNode to add ...

Read More

C# program to find K'th smallest element in a 2D array

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

Finding the K'th smallest element in a 2D array requires flattening the array and sorting it to locate the element at the K'th position. This is a common programming problem that demonstrates array manipulation and sorting techniques. Approach The approach involves three main steps − Flatten the 2D array into a 1D array Sort the flattened array in ascending order Access the element at index k-1 (since arrays are zero-indexed) Finding K'th Smallest Element 2D Array ...

Read More

Enum.GetNames in C#

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

The Enum.GetNames() method in C# retrieves an array of the names of constants in a specified enumeration. This method is useful when you need to dynamically access or display all the values defined in an enum without hardcoding them. Syntax Following is the syntax for the Enum.GetNames() method − public static string[] GetNames(Type enumType) Parameters enumType − The System.Type of the enumeration whose names you want to retrieve. Return Value Returns a string[] array containing the names of the constants in the specified enumeration, ordered by their ...

Read More

Buffer Type in C#

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

The Buffer class in C# provides efficient methods for manipulating arrays of primitive types at the byte level. It is particularly useful when you need to perform fast operations on large arrays or when working with binary data. The Buffer.BlockCopy method is the most commonly used method, which copies bytes from one array to another. Syntax Following is the syntax for the Buffer.BlockCopy method − Buffer.BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count); Parameters src − The source array from which bytes are copied srcOffset − The byte offset into ...

Read More

Insertion Sort in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 5K+ Views

Insertion Sort is a simple sorting algorithm that builds the sorted array one element at a time. It takes each element from the unsorted portion and inserts it into its correct position within the already sorted portion of the array. The algorithm works similarly to how you might sort playing cards in your hand − you pick up cards one by one and insert each into its proper position among the cards you've already sorted. How Insertion Sort Works The algorithm divides the array into two parts: a sorted portion (initially just the first element) and an ...

Read More

Thread-Safe collections in C#

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

Thread-safe collections in C# are specialized data structures designed for concurrent programming. The System.Collections.Concurrent namespace, introduced in .NET Framework 4, provides collections that allow multiple threads to safely add, remove, and access items without external synchronization. These collections use lightweight synchronization mechanisms like SpinLock and SpinWait to achieve thread safety while maintaining high performance and scalability. Thread-Safe Collections Overview Thread A Thread B Thread C Concurrent Collection ...

Read More
Showing 41–50 of 749 articles
« Prev 1 3 4 5 6 7 75 Next »
Advertisements