Server Side Programming Articles

Page 769 of 2109

What is the Values property of Hashtable class in C#?

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

The Values property of the Hashtable class in C# gets an ICollection containing all the values stored in the Hashtable. This property provides a way to access all values without needing to know their corresponding keys. Syntax Following is the syntax for using the Values property − public virtual ICollection Values { get; } To iterate through the values − foreach (object value in hashtable.Values) { // process each value } Return Value The Values property returns an ICollection object that contains all the values ...

Read More

How to calculate power of three using C#?

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

Calculating the power of a number in C# can be done using recursion, iteration, or built-in methods. This article demonstrates how to calculate powers with a focus on raising numbers to the power of 3, though the methods work for any exponent. Syntax Following is the syntax for a recursive power function − static long power(int baseNumber, int exponent) { if (exponent != 0) { return (baseNumber * power(baseNumber, exponent - 1)); } return 1; } ...

Read More

What is garbage collection in C#?

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 9K+ Views

The garbage collector (GC) in C# is an automatic memory management system that handles the allocation and release of memory for managed objects. It eliminates the need for manual memory management, preventing memory leaks and reducing programming errors. The garbage collector operates on the managed heap, where all reference type objects are stored. When objects are no longer referenced by the application, the GC automatically reclaims their memory space. How Garbage Collection Works Garbage Collection Process Object Created Memory Low ...

Read More

How to write multi-line comments in C#?

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

Multi-line comments in C# are comments that span more than one line. They are useful for adding detailed explanations, documenting code blocks, or temporarily disabling large sections of code during development. Syntax Multi-line comments in C# use the following syntax − /* This is a multi-line comment that can span multiple lines All text between /* and */ is ignored */ The compiler ignores everything between /* and */, making it perfect for lengthy explanations or code documentation. Basic Multi-line Comment Example using System; ...

Read More

C# program to print all the numbers divisible by 3 and 5 for a given number

Samual Sam
Samual Sam
Updated on 17-Mar-2026 6K+ Views

To print numbers divisible by both 3 and 5, we use the modulus operator % with the logical AND operator &&. A number is divisible by both 3 and 5 if the remainder is zero when divided by each of these numbers. Syntax Following is the syntax to check if a number is divisible by both 3 and 5 − if (num % 3 == 0 && num % 5 == 0) { // number is divisible by both 3 and 5 } Alternatively, since a number divisible by both 3 ...

Read More

How to assign same value to multiple variables in single statement in C#?

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

In C#, you can assign the same value to multiple variables in a single statement using the assignment operator. This technique is called chained assignment and works because the assignment operator returns the assigned value. Syntax Following is the syntax for assigning the same value to multiple variables − variable1 = variable2 = variable3 = value; The assignment is evaluated from right to left, so value is first assigned to variable3, then that result is assigned to variable2, and finally to variable1. How It Works The assignment operator (=) in C# returns ...

Read More

C# program to print all sublists of a list

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

A sublist (or subsequence) of a string contains characters from the original string in the same order, but not necessarily consecutive. For example, from the string "xyz", possible sublists include "x", "xy", "xz", "y", "yz", "z", and "xyz". This program generates all possible sublists of a given string by building them incrementally using nested loops and dynamic list operations. How the Algorithm Works The algorithm processes each character of the input string and creates new sublists by combining existing sublists with the current character. It maintains a list that grows with each iteration, containing all possible sublists ...

Read More

How to check if a C# list is empty?

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

In C#, there are several ways to check if a List is empty. The most common approaches include using the Count property, the Any() LINQ method, or comparing against an empty collection. Syntax Following are the common syntaxes for checking if a list is empty − // Using Count property if (list.Count == 0) { } // Using Any() method if (!list.Any()) { } // Using Count with comparison if (list.Count > 0) { } Using Count Property The Count property returns the number of elements in the list. When Count ...

Read More

IS vs AS Operators in C#

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 1K+ Views

The is and as operators in C# are used for type checking and type conversion. The is operator checks if an object is compatible with a given type and returns a boolean value, while the as operator attempts to convert an object to a specified type and returns null if the conversion fails. Syntax Following is the syntax for the is operator − expr is type Following is the syntax for the as operator − expr as type Where expr is the expression to test and type is the target ...

Read More

static keyword in C#

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

The static keyword in C# is used to declare class members that belong to the class itself rather than to any specific instance. When a member is declared as static, it means there is only one copy of that member shared across all instances of the class. Static members can be accessed directly using the class name without creating an object instance. They are commonly used for utility methods, constants, and shared data that should be consistent across all instances of a class. Syntax Following is the syntax for declaring static members − public static ...

Read More
Showing 7681–7690 of 21,090 articles
« Prev 1 767 768 769 770 771 2109 Next »
Advertisements