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
Csharp Articles
Page 173 of 196
Validate IP Address in C#
An IP Address is an Internet Protocol address that is a series of numbers assigned to each device on a computer network. In C#, the IPAddress class in the System.Net namespace provides methods to work with and validate IP addresses. There are several approaches to validate IP addresses in C#, including using the built-in IPAddress.TryParse() method and regular expressions for custom validation. Syntax Following is the syntax for using IPAddress.TryParse() method − bool IPAddress.TryParse(string ipString, out IPAddress address) Parameters ipString − A string that contains an IP address in dotted-decimal notation ...
Read MoreC# program to perform Quick sort using Recursion
Quick Sort is a highly efficient sorting algorithm that uses the divide and conquer approach. It selects a pivot element from the array and partitions the other elements into two sub-arrays according to whether they are less than or greater than the pivot. The sub-arrays are then recursively sorted. The algorithm works by placing the pivot in its correct position and then recursively applying the same process to the left and right sub-arrays until the entire array is sorted. How Quick Sort Works Quick Sort Process Initial Array: ...
Read MoreHow to perform Merge Sort using C#?
Merge Sort is a sorting algorithm that uses the divide and conquer method. It divides the array into two halves, recursively sorts each half, and then merges them back together in sorted order. This process continues until the entire array is sorted. How Merge Sort Works Merge Sort follows these steps − Divide: Split the array into two halves at the middle point Conquer: Recursively sort both halves Merge: Combine the two sorted halves into a single sorted array Merge Sort Divide and Conquer ...
Read MoreHow to multiply a given number by 2 using Bitwise Operators in C#?
A number can be multiplied by 2 using bitwise operators. This is done by using the left shift operator (
Read MoreDictionary.ContainsKey() Method in C#
The Dictionary.ContainsKey() method in C# checks whether the Dictionary contains the specified key. This method returns true if the key exists, otherwise false. Syntax public bool ContainsKey(TKey key); Parameters key − The key to locate in the dictionary. Cannot be null for reference types. Return Value Returns true if the dictionary contains an element with the specified key; otherwise, false. Using ContainsKey() to Check for Existing Keys This example demonstrates checking for a key that exists in the dictionary − using System; using System.Collections.Generic; public class Demo ...
Read MoreDictionary.ContainsValue() Method in C#
The Dictionary.ContainsValue() method in C# is used to check whether the Dictionary contains a specific value or not. This method returns true if the value is found in the dictionary, otherwise it returns false. Syntax public bool ContainsValue(TValue val); Parameters val − The value to search for in the dictionary. This parameter can be null if the value type allows null values. Return Value Returns true if the dictionary contains the specified value; otherwise, false. Using ContainsValue() with Found Value The following example demonstrates checking for a value that exists ...
Read MoreChar.IsControl(String, Int32) Method in C#
The Char.IsControl(String, Int32) method in C# determines whether the character at a specified position in a string is a control character. Control characters are non-printable characters used for formatting and text control, such as tab (\t), newline (), and carriage return (\r). Syntax Following is the syntax for the Char.IsControl(String, Int32) method − public static bool IsControl(string str, int index); Parameters str − The string to examine. index − The zero-based position of the character to evaluate in the string. Return Value Returns true if ...
Read MoreChar.IsSymbol() Method in C#
The Char.IsSymbol() method in C# determines whether a specified character is categorized as a symbol character. Symbol characters include mathematical symbols, currency symbols, and other non-alphanumeric characters that are not punctuation or control characters. Syntax The method has two overloads − public static bool IsSymbol(char c); public static bool IsSymbol(string str, int index); Parameters c − The Unicode character to evaluate. str − A string containing the character to evaluate. index − The position of the character to evaluate in the string. Return Value Returns true if the character ...
Read MoreCharEnumerator.Clone() Method in C#
The CharEnumerator.Clone() method in C# is used to create a copy of the current CharEnumerator object. This method returns an object that must be cast to CharEnumerator to use its functionality. The cloned enumerator maintains the same position as the original enumerator at the time of cloning. Syntax public object Clone(); Return Value Returns an object that is a copy of the current CharEnumerator instance. The returned object must be cast to CharEnumerator to access enumerator-specific methods. Using CharEnumerator.Clone() The following example demonstrates how to create and use a cloned CharEnumerator − ...
Read MoreCharEnumerator.Dispose() Method in C#
The CharEnumerator.Dispose() method in C# is used to release all resources used by the current instance of the CharEnumerator class. This method implements the IDisposable interface and should be called when you're finished using the enumerator to ensure proper resource cleanup. Syntax Following is the syntax for the CharEnumerator.Dispose() method − public void Dispose(); Parameters This method does not take any parameters. Return Value This method does not return any value (void). Using CharEnumerator.Dispose() Method Example 1: Basic Usage The following example demonstrates how to use the Dispose() ...
Read More