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
How to convert string to title case in C#?
Title case is any text, such as in a title or heading, where the first letter of major words is capitalized. Title case or headline case is a style of capitalization used for rendering the titles of published works or works of art in English. When using title case, all words are capitalized except for minor words (like articles, prepositions, and conjunctions) unless they are the first or last word of the title. C# provides the ToTitleCase method through the TextInfo class to convert strings to title case format. This method capitalizes the first letter of each word while ...
Read MoreHow to check whether the tree is symmetric or not using iterative in C#?
A symmetric binary tree is one where the left subtree is a mirror reflection of the right subtree. In the iterative approach, we use two queues to traverse both subtrees simultaneously and compare their values in mirror positions. The algorithm works by enqueueing nodes from the left and right subtrees in opposite orders. For the left subtree, we add left child first, then right child. For the right subtree, we add right child first, then left child. This ensures we compare mirror positions correctly. Syntax Following is the basic structure for checking tree symmetry iteratively − ...
Read MoreCheck if two StringBuilder objects are Equal in C#
To check if two StringBuilder objects are equal in C#, you need to understand that StringBuilder.Equals() checks for reference equality, not content equality. For content comparison, you must convert the StringBuilder objects to strings first. Syntax Following is the syntax for checking StringBuilder equality − // Reference equality bool isEqual = stringBuilder1.Equals(stringBuilder2); // Content equality bool isContentEqual = stringBuilder1.ToString().Equals(stringBuilder2.ToString()); Using Reference Equality The Equals() method on StringBuilder checks if both objects reference the same instance − using System; using System.Text; public class Demo { public static ...
Read MoreCopy StringDictionary to Array at the specified index in C#
The StringDictionary class in C# provides the CopyTo() method to copy its key-value pairs to a DictionaryEntry array starting at a specified index. This method is useful when you need to convert dictionary data into an array format for processing or manipulation. Syntax The syntax for copying a StringDictionary to an array at a specified index is − stringDictionary.CopyTo(array, index); Parameters array − The destination DictionaryEntry[] array where elements will be copied. index − The zero-based index in the array where copying begins. Using CopyTo() Starting at Index 0 ...
Read MoreHow to use String Format to show decimal up to 2 places or simple integer in C#?
The String.Format method in C# converts values to formatted strings and inserts them into another string. It's particularly useful for displaying numbers with consistent decimal places, showing integers as decimals when needed, or keeping integers without unnecessary decimal points. Syntax Following is the syntax for String.Format with decimal formatting − string.Format("{0:format}", value) Common decimal format specifiers − "{0:0.00}" // Always shows 2 decimal places "{0:F2}" // Fixed-point with 2 decimal places "{0:N2}" // Number format with 2 decimal places ...
Read MoreC# Program to Find out the value of Sin(x)
In this article, we will learn how to create a C# program to find the value of Sin(x). The sine function is a fundamental trigonometric function that calculates the ratio of the opposite side to the hypotenuse in a right triangle. C# provides built-in methods to calculate sine values, and we can also implement our own calculation using mathematical series. Syntax C# provides a built-in method in the Math class to calculate sine values − Math.Sin(double angleInRadians) The Maclaurin series expansion for sin(x) is − sin(x) = x - x³/3! + x⁵/5! ...
Read MoreHow to check whether the tree is symmetric or not using recursion in C#?
A symmetric binary tree is a tree where the left subtree is a mirror image of the right subtree. In C#, we can check if a tree is symmetric using recursion by comparing corresponding nodes from left and right subtrees. The recursive approach works by first checking if the tree is null (which is symmetric by definition), then calling a helper method to compare the left and right subtrees as mirror images of each other. Algorithm Steps If the root is null, the tree is symmetric Compare left subtree with right subtree using a mirror comparison ...
Read MoreCheck if two Tuple Objects are equal in C#
To check if two Tuple objects are equal in C#, you can use the Equals() method or the equality operator (==). Tuples are compared element-wise, meaning all corresponding elements must be equal for the tuples to be considered equal. Syntax Following is the syntax for comparing tuples using the Equals() method − bool result = tuple1.Equals(tuple2); You can also use the equality operator − bool result = tuple1 == tuple2; How Tuple Equality Works Tuple equality comparison follows these rules: Both tuples must have the same number ...
Read MoreCopy the elements of collection over a range of elements in ArrayList in C#
The SetRange() method in C# ArrayList allows you to copy elements from a collection over a specific range of elements in the ArrayList. This method replaces existing elements starting from the specified index with elements from the source collection. Syntax Following is the syntax for the SetRange() method − public virtual void SetRange(int index, ICollection c) Parameters index − The zero-based index in the ArrayList at which to start copying elements. c − The ICollection whose elements are to be copied to the ArrayList. The collection itself cannot be ...
Read MoreC# Program to find the greatest number in an array using the WHERE clause LINQ
In this article, we will find the greatest number in an array using the WHERE clause in LINQ. LINQ (Language Integrated Query) provides a unified way to query data from different sources in C#, making code more readable and concise with built-in filtering, sorting, and grouping capabilities. Language Integrated Query (LINQ) LINQ is a component of the .NET framework that allows type-safe data access from various sources like databases, XML documents, and collections. It uses clauses to perform different operations on data − From Clause − Specifies the data source and range variable. Where Clause − ...
Read More