Programming Articles

Page 718 of 2547

MathF.Cbrt() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 162 Views

The MathF.Cbrt() method in C# is used to return the cube root of a floating-point value. This method is part of the System namespace and works specifically with float data types, providing better performance than the generic Math.Cbrt() method when working with single-precision floating-point numbers. Syntax Following is the syntax − public static float Cbrt(float val); Parameters val − A floating-point number whose cube root is to be calculated. Return Value Returns a float value representing the cube root of the specified number. If the input is NaN (Not ...

Read More

C# Object.GetType() Method with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 3K+ Views

The Object.GetType() method in C# is used to get the runtime type of the current instance. This method is inherited by all types in C# since every type derives from Object. It returns a Type object that contains metadata about the type. Syntax Following is the syntax for the GetType() method − public Type GetType(); Return Value The method returns a Type object that represents the exact runtime type of the current instance. Using GetType() with Built-in Types The GetType() method can be called on any object to determine its type ...

Read More

Get the last node of the LinkedList in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 364 Views

In C#, you can get the last node of a LinkedList using the Last property. This property returns a LinkedListNode object representing the last node in the list, or null if the list is empty. Syntax Following is the syntax to get the last node of a LinkedList − LinkedListNode lastNode = linkedList.Last; T lastValue = linkedList.Last.Value; Using Last Property with String LinkedList The following example demonstrates how to access the last node in a string LinkedList − using System; using System.Collections.Generic; public class Demo { public ...

Read More

How to find all the different combinations of opening and closing brackets from the given number k using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 465 Views

Finding all valid combinations of opening and closing brackets for a given number k is a classic backtracking problem in computer science. This problem generates all possible arrangements of k pairs of brackets where each opening bracket has a corresponding closing bracket in the correct order. The solution uses a recursive backtracking approach that builds valid bracket combinations by placing opening brackets when available and closing brackets only when they don't exceed the number of opening brackets already placed. Algorithm Overview The backtracking algorithm follows these key rules − Add an opening bracket if ...

Read More

MathF.Ceiling() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 501 Views

The MathF.Ceiling() method in C# is used to find the smallest integer greater than or equal to the specified float value. This method always rounds up to the next integer, even for negative numbers. Syntax Following is the syntax − public static float Ceiling (float val); Parameters val − A floating-point number whose ceiling value is to be calculated. Return Value Returns a float representing the smallest integer that is greater than or equal to the input value. MathF.Ceiling() Visualization ...

Read More

C# Queue.TrimExcess() Method with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 368 Views

The Queue.TrimExcess() method in C# is used to set the capacity to the actual number of elements in the Queue, if that number is less than 90 percent of current capacity. This method helps optimize memory usage by reducing the internal array size when the queue has significantly fewer elements than its current capacity. Syntax public void TrimExcess(); Parameters: This method takes no parameters. Return Value: This method does not return any value (void). How It Works The TrimExcess() method only reduces capacity when the current element count is less than 90% ...

Read More

Get the maximum value in the SortedSet in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 212 Views

The SortedSet class in C# provides the Max property to efficiently retrieve the maximum value from the collection. Since SortedSet maintains elements in sorted order, the maximum element is always the last element in the collection. Syntax Following is the syntax for getting the maximum value from a SortedSet − SortedSet sortedSet = new SortedSet(); T maxValue = sortedSet.Max; Properties Property Description Return Type Max Gets the maximum value in the SortedSet according to the comparer. T Min Gets the minimum value in the ...

Read More

How to find the minimum number of steps needed by knight to reach the destination using C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 404 Views

In chess, a knight moves in an L-shape − two squares in one direction and one square perpendicular to that. This article explains how to find the minimum number of steps (moves) needed for a knight to reach a destination cell on a chessboard using Breadth-First Search (BFS) algorithm in C#. The knight's movement pattern creates a shortest path problem that can be efficiently solved using BFS, as it explores all possible moves level by level, guaranteeing the minimum number of steps. Knight's Movement Pattern A knight can move to at most 8 positions from any given ...

Read More

Uri.IsBaseOf(Uri) Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 221 Views

The Uri.IsBaseOf() method in C# is used to determine whether the current Uri instance is a base of the specified Uri instance. This method is particularly useful when working with URL hierarchies and checking if one URI is a parent or base path of another URI. Syntax Following is the syntax − public bool IsBaseOf(Uri uri); Parameters uri − The specified Uri instance to test against the current Uri instance. Return Value Returns true if the current Uri instance is a base of the specified Uri; otherwise, false. ...

Read More

C# String Operators

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 640 Views

C# provides several string operators that allow you to perform operations and comparisons on strings. The primary string operators include equality (==), inequality (!=), and the concatenation operator (+). These operators make string manipulation and comparison straightforward and intuitive. Syntax Following is the syntax for string comparison operators − bool result = string1 == string2; // Equality bool result = string1 != string2; // Inequality string result = string1 + string2; // Concatenation String Equality Operator (==) The equality operator checks if two strings have the same content. It performs a ...

Read More
Showing 7171–7180 of 25,466 articles
« Prev 1 716 717 718 719 720 2547 Next »
Advertisements