Articles on Trending Technologies

Technical articles with clear explanations and examples

Complex Numbers in C#

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

A complex number in C# consists of two components: a real part and an imaginary part. For example, in the complex number 7+5i, the real part is 7 and the imaginary part is 5 (the coefficient of i). C# allows you to create custom data structures to represent complex numbers using struct and implement mathematical operations using operator overloading. Syntax Following is the syntax for creating a complex number structure − public struct Complex { public double real; public double imaginary; public ...

Read More

What is the C# equivalent of C++ friend keyword?

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

In C++, the friend keyword allows external functions or classes to access private and protected members of a class. C# does not have a direct equivalent to the friend keyword, but there are several approaches to achieve similar functionality. Understanding the friend Concept A friend function in C++ is defined outside a class but has access to all private and protected members of that class. While C# doesn't support this directly, it provides alternative mechanisms to control access between closely related classes. Using Nested Classes The closest equivalent to C++ friend functionality is using nested classes. ...

Read More

Compilation and Execution of a C# Program

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

To compile and execute a program in C#, you can use several methods depending on your development environment. The most common approaches include using Visual Studio IDE, command-line tools, or online compilers. Using Visual Studio IDE In Microsoft Visual Studio IDE, compilation and execution is straightforward − Click the Run button or press F5 key to build and execute the project. Visual Studio automatically compiles your code and runs the executable. Any compilation errors will appear in the Error List window. Command-Line Compilation You can compile C# programs using the command-line C# compiler ...

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 convert a JavaScript array to C# array?

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

Converting a JavaScript array to a C# array involves passing the JavaScript array data to your C# application, typically through web forms, AJAX requests, or by converting the array to a string format that C# can parse. The most common approach is to serialize the JavaScript array to a string (usually comma-separated or JSON format) and then parse it in C# to recreate the array. Using Comma-Separated String Conversion First, convert the JavaScript array to a comma-separated string using the join() method − var myArr = ["Welcome", "to", "the", "Web", "World"]; ...

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

How to access elements from a rectangular array in C#?

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

To access elements from a rectangular array in C#, you need to specify the row and column indices using square brackets. Multi-dimensional arrays are also called rectangular arrays because they form a rectangular structure with fixed dimensions. Syntax Following is the syntax for accessing elements in a rectangular array − dataType[, ] arrayName = new dataType[rows, columns]; arrayName[rowIndex, columnIndex] = value; To retrieve an element − dataType element = arrayName[rowIndex, columnIndex]; Rectangular Array Structure Columns 0 1 2 ...

Read More

How to print all the Armstrong Numbers from 1 to 1000 using C#?

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

An Armstrong number (also called a narcissistic number) is a number that equals the sum of its own digits raised to the power of the number of digits. For 3-digit numbers, each digit is cubed and summed. For example, 153 is an Armstrong number because 1³ + 5³ + 3³ = 1 + 125 + 27 = 153. To find all Armstrong numbers from 1 to 1000, we need to check each number by extracting its digits, calculating the sum of cubes, and comparing it with the original number. Algorithm The steps to identify Armstrong numbers are ...

Read More

What is the C# equivalent to Java's isInstance()?

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

Java's isInstance() method determines if a specified object is assignment-compatible with the object represented by a class. In C#, there are several equivalent approaches to achieve the same functionality for type checking and instance validation. C# Equivalents to Java's isInstance() The most common C# equivalents are the is operator, IsAssignableFrom() method, and IsInstanceOfType() method. Each serves different use cases depending on whether you're working with objects, types, or need runtime type checking. Using the 'is' Operator The simplest and most commonly used equivalent is the is operator − bool result = (object is ClassName); ...

Read More

How to remove items from a list in C#?

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

In C#, there are several ways to remove items from a List. The most commonly used methods are Remove(), RemoveAt(), RemoveAll(), and Clear(). Each method serves different purposes depending on whether you want to remove by value, by index, by condition, or all items. Syntax Following are the common syntaxes for removing items from a list − // Remove by value list.Remove(item); // Remove by index list.RemoveAt(index); // Remove all items matching a condition list.RemoveAll(predicate); // Remove all items list.Clear(); Using Remove() Method The Remove() method removes the first occurrence ...

Read More
Showing 11291–11300 of 61,297 articles
Advertisements