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
Programming Articles
Page 96 of 2547
C# Int32 Struct
The Int32 struct in C# represents a 32-bit signed integer. It is an immutable value type that represents signed integers with values ranging from -2, 147, 483, 648 to 2, 147, 483, 647. The int keyword in C# is an alias for Int32. This struct provides various fields and methods for working with 32-bit integers, including comparison, parsing, and conversion operations. Syntax Following is the syntax for declaring an Int32 variable − int variableName = value; Int32 variableName = value; Fields The Int32 struct provides two important constant fields − ...
Read MoreC# Int16.ToString() Method
The Int16.ToString() method in C# is used to convert a 16-bit signed integer (short) to its equivalent string representation. This method provides multiple overloads to format the output string according to your specific requirements. Syntax Following are the different overloads of the Int16.ToString() method − public override string ToString(); public string ToString(string format); public string ToString(IFormatProvider provider); public string ToString(string format, IFormatProvider provider); Parameters format − A numeric format string that specifies the format of the return value. provider − An object that supplies culture-specific formatting information. ...
Read MoreHow to search in a row wise and column wise increased matrix using C#?
A row-wise and column-wise sorted matrix has elements arranged in ascending order both horizontally (across rows) and vertically (down columns). This creates a special structure that allows for efficient searching algorithms beyond simple linear traversal. The most straightforward approach is to treat the sorted 2D matrix as a flattened 1D array and apply binary search. Since elements maintain sorted order when concatenated row by row, we can use index mapping to convert 1D positions back to 2D coordinates. Syntax Following is the syntax for converting between 1D and 2D indices in a matrix − // ...
Read MoreSingle.GetTypeCode Method in C# with Examples
The Single.GetTypeCode() method in C# is used to return the TypeCode for the Single value type (also known as float). This method is inherited from the IConvertible interface and always returns TypeCode.Single for any float value. Syntax Following is the syntax for the Single.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.Single, which is an enumerated constant representing the Single data type. Using GetTypeCode with Different Float Values Example using System; public class Demo { public static void Main() { ...
Read MoreHow to find the MaxCapacity of a StringBuilder in C#?
The MaxCapacity property of a StringBuilder in C# returns the maximum number of characters that the StringBuilder can hold. This is a read-only property that represents the theoretical upper limit for the StringBuilder's capacity. In most cases, the MaxCapacity is set to Int32.MaxValue (2, 147, 483, 647), which is the maximum value for a 32-bit signed integer. However, you can specify a custom maximum capacity when creating a StringBuilder using specific constructor overloads. Syntax Following is the syntax to access the MaxCapacity property − int maxCapacity = stringBuilder.MaxCapacity; Following is the syntax to ...
Read MoreStack.Pop() Method in C#
The Stack.Pop() method in C# is used to remove and return the object at the top of the Stack. This method follows the LIFO (Last In, First Out) principle, where the most recently added element is the first one to be removed. Syntax Following is the syntax for the Pop() − public virtual object Pop(); Return Value The Pop() method returns the object that was removed from the top of the Stack. If the Stack is empty, it throws an InvalidOperationException. How Stack.Pop() Works Stack.Pop() Operation ...
Read MoreOrderedDictionary Class in C#
The OrderedDictionary class in C# represents a collection of key/value pairs that maintains insertion order and allows access by both key and index. It combines the functionality of a dictionary with the ordered nature of a list, making it useful when you need to preserve the order of items while still providing fast key-based lookup. Syntax Following is the syntax for creating and using an OrderedDictionary − OrderedDictionary dict = new OrderedDictionary(); dict.Add(key, value); dict[key] = value; // Access by key dict[index] = value; // Access by index ...
Read MoreWhat is the Item property of BitArray class in C#?
The Item property of the BitArray class in C# gets or sets the value of the bit at a specific position in the BitArray. This property acts as an indexer, allowing you to access individual bits using bracket notation like bitArray[index]. The Item property provides a convenient way to read and modify individual bits without having to use explicit method calls. It returns a bool value representing the bit state at the specified index. Syntax Following is the syntax for accessing the Item property − public bool this[int index] { get; set; } ...
Read MoreC# program to find Largest, Smallest, Second Largest, Second Smallest in a List
Finding the largest, smallest, second largest, and second smallest elements in a list is a common programming task in C#. Using LINQ methods like Max(), Min(), OrderBy(), and Skip() provides an elegant solution for these operations. Syntax To find the largest element − list.Max() To find the smallest element − list.Min() To find the second largest element − list.OrderByDescending(x => x).Skip(1).First() To find the second smallest element − list.OrderBy(x => x).Skip(1).First() Using LINQ Methods The most straightforward approach uses LINQ extension ...
Read MoreHow to access array elements using a pointer in C#?
In C#, accessing array elements using pointers requires understanding the key differences between arrays and pointers. An array name and a pointer to the same data type are not the same variable type. For example, int *p and int[] p represent different types. You can increment a pointer variable because it's not fixed in memory, but an array address is fixed in memory and cannot be incremented directly. To access array elements using pointers in C#, you must use unsafe code and the fixed statement to pin the array in memory temporarily. Syntax Following is the syntax ...
Read More