Csharp Articles

Page 169 of 196

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

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 149 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

How to find minimum between 2 numbers using C#?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 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

Difference between C# and Visual C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 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

What is the IsReadOnly property of ArrayList class in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 203 Views

The IsReadOnly property of the ArrayList class in C# returns a boolean value indicating whether the ArrayList is read-only. A read-only ArrayList cannot be modified after creation − you cannot add, remove, or change elements. Syntax Following is the syntax for using the IsReadOnly property − bool isReadOnly = arrayList.IsReadOnly; Return Value The IsReadOnly property returns − true − if the ArrayList is read-only false − if the ArrayList can be modified Using IsReadOnly with Regular ArrayList A regular ArrayList created using the default constructor is always modifiable, ...

Read More

What is the Length property of BitArray class in C#?

Samual Sam
Samual Sam
Updated on 17-Mar-2026 144 Views

The Length property of the BitArray class in C# is used to get or set the number of elements in the BitArray. This property allows you to determine the size of the bit array and also resize it when needed. Syntax Following is the syntax for using the Length property − public int Length { get; set; } Return Value The Length property returns an int value representing the number of elements in the BitArray. Using Length Property to Get BitArray Size You can use the Length property to determine how ...

Read More

How to Initialize and Compare Strings in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 310 Views

String initialization and comparison are fundamental operations in C# programming. C# provides multiple ways to initialize strings and several methods to compare them effectively. String Initialization There are several ways to initialize a string in C# − // Direct assignment string str1 = "Hello, World!"; // Using string constructor string str2 = new string("Welcome"); // Empty string initialization string str3 = ""; string str4 = string.Empty; Example using System; class Program { static void Main(string[] args) { ...

Read More

How to find maximum between 2 numbers using C#?

George John
George John
Updated on 17-Mar-2026 2K+ Views

Finding the maximum between two numbers in C# can be accomplished using several approaches. The most common methods include using conditional statements, the Math.Max() method, and the ternary operator. Using If-Else Statement The traditional approach uses an if-else statement to compare two numbers and determine which one is larger − using System; class Program { static void Main(string[] args) { int num1 = 50; int num2 = 90; ...

Read More

How to create a thread in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 755 Views

Threads are lightweight processes that represent independent execution paths within a program. In C#, threads are created using the Thread class from the System.Threading namespace. Creating threads enables concurrent programming, allowing multiple operations to run simultaneously and improving application efficiency. Modern operating systems use threads to implement concurrent programming, which saves CPU cycles and increases application performance by allowing multiple tasks to execute in parallel. Syntax Following is the basic syntax for creating a thread in C# − Thread threadName = new Thread(methodName); threadName.Start(); You can also use a ThreadStart delegate to wrap ...

Read More

How to create an infinite loop in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 2K+ Views

An infinite loop is a loop that never terminates and repeats indefinitely. While infinite loops are generally undesirable in most applications, they can be useful in specific scenarios like game loops, server applications, or continuous monitoring systems. There are several ways to create infinite loops in C#, each with different syntax and use cases. Using For Loop The most common way to create an infinite loop is by manipulating the loop condition so it never becomes false − using System; class Program { static void Main(string[] args) { ...

Read More

How to create custom attributes in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 363 Views

Custom attributes in C# allow you to store declarative information about program elements (classes, methods, properties, etc.) that can be retrieved at runtime using reflection. They provide metadata that doesn't affect program execution but can be used for documentation, validation, or configuration purposes. Syntax Following is the basic syntax for creating a custom attribute − [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] public class CustomAttribute : System.Attribute { // constructors and properties } Following is the syntax for applying the custom attribute − [CustomAttribute(parameters)] public class MyClass { // class ...

Read More
Showing 1681–1690 of 1,951 articles
« Prev 1 167 168 169 170 171 196 Next »
Advertisements