Programming Articles

Page 105 of 2547

Enum.GetNames in C#

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 94 Views

The Enum.GetNames() method in C# retrieves an array of the names of constants in a specified enumeration. This method is useful when you need to dynamically access or display all the values defined in an enum without hardcoding them. Syntax Following is the syntax for the Enum.GetNames() method − public static string[] GetNames(Type enumType) Parameters enumType − The System.Type of the enumeration whose names you want to retrieve. Return Value Returns a string[] array containing the names of the constants in the specified enumeration, ordered by their ...

Read More

C# into keyword

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 173 Views

The into keyword in C# LINQ is used to create intermediate query expressions. It allows you to continue a query after a select or group clause by introducing a new range variable that represents the results of the previous query operation. Syntax Following is the syntax for using the into keyword in LINQ queries − from element in collection select expression into newVariable where condition select finalExpression The into keyword can also be used with group operations − from element in collection group element by key into groupVariable where groupCondition select groupExpression ...

Read More

What are the C++ features missing in C#?

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

C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg. While C# and C++ share some similarities, there are several key features present in C++ that are either missing or implemented differently in C#. C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms and provides more direct hardware control compared to C#. Key C++ Features Missing in C# Multiple Inheritance C++ supports multiple inheritance, allowing a class to inherit from multiple base ...

Read More

How to check if array contains a duplicate number using C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 1K+ Views

Checking if an array contains duplicate numbers is a common programming task in C#. There are multiple approaches to solve this problem, ranging from simple loops to LINQ methods and hash-based techniques. Using Dictionary to Count Occurrences The dictionary approach counts the frequency of each element in the array. Any element with a count greater than 1 is a duplicate − using System; using System.Collections.Generic; namespace Demo { public class Program { public static void Main(string[] args) { ...

Read More

C# NullReferenceException

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

A NullReferenceException is one of the most common runtime exceptions in C#. It occurs when you try to access a member (property, method, or field) of an object reference that is null. When NullReferenceException Occurs This exception is thrown when − You call a method on a null reference You access or modify a property of a null reference You get the length of a null array or string You index into a null array NullReferenceException Flow ...

Read More

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

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

How do you loop through a C# array?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 6K+ Views

To loop through an array in C#, you can use several loop types including for, foreach, while, and do...while loops. Each loop provides different ways to iterate through array elements and access their values. The most commonly used loops for arrays are the for loop (when you need index access) and the foreach loop (when you only need element values). Syntax Following is the syntax for different loop types with arrays − // for loop for (int i = 0; i < array.Length; i++) { // access array[i] } // ...

Read More

Singleton Class in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 3K+ Views

A Singleton class in C# is a design pattern that ensures only one instance of a class can be created throughout the application's lifetime. It provides a global point of access to that instance and is commonly used for logging, database connections, and configuration management. The key principle of the Singleton pattern is to restrict instantiation of a class to a single object by using a private constructor and providing a static method or property to access the instance. Syntax Following is the basic syntax for implementing a Singleton class − public class Singleton { ...

Read More

Combine two arrays in C#

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

Combining two arrays in C# can be accomplished using various methods. The most common approaches include using List.AddRange() method, Array.Copy(), or LINQ's Concat() method. Syntax Using List.AddRange() method − var list = new List(); list.AddRange(array1); list.AddRange(array2); T[] combinedArray = list.ToArray(); Using Array.Copy() method − T[] combinedArray = new T[array1.Length + array2.Length]; Array.Copy(array1, 0, combinedArray, 0, array1.Length); Array.Copy(array2, 0, combinedArray, array1.Length, array2.Length); Using LINQ Concat() method − T[] combinedArray = array1.Concat(array2).ToArray(); Using List.AddRange() Method This approach creates a List, adds both arrays using AddRange(), then converts ...

Read More

C# Convert.ToInt32 Method

George John
George John
Updated on 17-Mar-2026 862 Views

The Convert.ToInt32 method in C# is used to convert various data types to a 32-bit signed integer. It is commonly used to convert strings, floating-point numbers, and other numeric types to integers, providing a versatile approach to type conversion. Syntax Following are the most common syntax forms for Convert.ToInt32 − Convert.ToInt32(value); Convert.ToInt32(value, fromBase); Parameters value − The value to convert (string, double, decimal, bool, etc.) fromBase − Optional. The base of the number system (2, 8, 10, or 16) Return Value Returns a 32-bit signed integer equivalent to the ...

Read More
Showing 1041–1050 of 25,467 articles
« Prev 1 103 104 105 106 107 2547 Next »
Advertisements