What is the Item property of SortedList class in C#?

karthikeya Boyini
Updated on 17-Mar-2026 07:04:35

157 Views

The Item property of the SortedList class in C# gets and sets the value associated with a specific key in the SortedList. It allows you to access and modify elements using the indexer syntax [key], making SortedList operations intuitive and similar to working with arrays or dictionaries. The Item property can also be used to add new elements directly. If the key does not exist, it creates a new key-value pair. If the key already exists, it overwrites the existing value with the new one. Syntax Following is the syntax for using the Item property − ... Read More

Math Class Fields with Examples in C#

AmitDiwan
Updated on 17-Mar-2026 07:04:35

219 Views

The Math class in C# provides essential mathematical constants through predefined fields. The two most commonly used fields are Math.E (Euler's number) and Math.PI (pi), which represent fundamental mathematical constants used in various calculations. These fields are declared as public const double, making them accessible throughout your application without needing to instantiate the Math class. Math.E Field The Math.E field represents Euler's number, which is the natural logarithmic base. This constant is approximately equal to 2.718281828 and is frequently used in exponential and logarithmic calculations. Syntax public const double E = 2.71828182845905; ... Read More

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

Arjun Thakur
Updated on 17-Mar-2026 07:04:35

509 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

Bool Array in C#

George John
Updated on 17-Mar-2026 07:04:35

10K+ Views

A bool array in C# is used to store multiple boolean values (true and false) in a single collection. Boolean arrays are useful for tracking states, flags, or conditions across multiple elements. Syntax Following are the different ways to declare and initialize a bool array − // Declaration with size bool[] arrayName = new bool[size]; // Declaration with initialization bool[] arrayName = {true, false, true}; // Using new keyword with values bool[] arrayName = new bool[] {true, false, true}; Creating and Initializing Bool Arrays Method 1: Declaration with Size and Assignment ... Read More

How to find minimum between 2 numbers using C#?

Samual Sam
Updated on 17-Mar-2026 07:04:35

2K+ Views

Finding the minimum between two numbers in C# can be accomplished using several approaches. The most common methods include using conditional statements like if-else or utilizing built-in methods like Math.Min(). Using if-else Statement The traditional approach uses an if-else statement to compare two numbers and determine the smaller value − using System; class Program { static void Main(string[] args) { int num1 = 50; int num2 = 90; int minNum; ... Read More

UInt32.GetTypeCode() Method in C# with Examples

AmitDiwan
Updated on 17-Mar-2026 07:04:35

169 Views

The UInt32.GetTypeCode() method in C# returns the TypeCode enumeration value for the UInt32 data type. This method is inherited from the IConvertible interface and is used to identify the underlying type of a value at runtime. The TypeCode enumeration provides a way to categorize the fundamental data types in .NET, making it useful for type checking and conversion operations. Syntax Following is the syntax for the UInt32.GetTypeCode() method − public TypeCode GetTypeCode(); Return Value This method returns TypeCode.UInt32, which represents the enumerated constant for the 32-bit unsigned integer type. Using GetTypeCode() ... Read More

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

Arjun Thakur
Updated on 17-Mar-2026 07:04:35

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

Default operator in C#

Ankith Reddy
Updated on 17-Mar-2026 07:04:35

743 Views

The default operator in C# returns the default value for any data type. For value types, it returns zero or false, while for reference types, it returns null. The default expressions are evaluated at compile-time, making them efficient for initialization. Starting with C# 7.1, you can use the simplified default literal when the type can be inferred from the context. Syntax Following is the syntax for the traditional default operator − default(Type) Following is the syntax for the simplified default literal (C# 7.1+) − Type variable = default; Default ... Read More

Implicit conversion from Int16 to Decimal in C#

Samual Sam
Updated on 17-Mar-2026 07:04:35

313 Views

The short type in C# represents a 16-bit signed integer (Int16) that can store values from -32, 768 to 32, 767. C# allows implicit conversion from short to decimal because this conversion is always safe and will never result in data loss. An implicit conversion means the compiler automatically performs the type conversion without requiring an explicit cast operator. This is possible because decimal has a much larger range and precision than short. Syntax The syntax for implicit conversion from Int16 to Decimal is straightforward − short shortValue = value; decimal decimalValue = shortValue; ... Read More

Difference between C# and Visual C#

Arjun Thakur
Updated on 17-Mar-2026 07:04:35

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

Advertisements