Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 14 of 81

How to print a line on the console using C#?

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

To display a line on the console in C#, we use the Console.WriteLine() method. This method prints text to the console and automatically adds a new line at the end. Syntax Following is the syntax for printing a line to the console − Console.WriteLine(value); Where value can be a string, variable, or any expression that can be converted to a string. Using Console.WriteLine() with Strings The most common use is to print string literals or string variables − using System; public class Program { public static ...

Read More

C# Queryable LongCount Method

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

The LongCount() method in C# is part of the System.Linq namespace and returns the number of elements in a sequence as a long data type. This method is particularly useful when dealing with large collections where the count might exceed the range of an int (2, 147, 483, 647). The LongCount() x % 2 == 0); Console.WriteLine("Even numbers: {0}", evenCount); long greaterThanFive = numbers.AsQueryable().LongCount(x => x > 5); ...

Read More

C# Program to filter array elements based on a predicate

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

In C#, filtering array elements based on a predicate allows you to select elements that meet specific conditions. A predicate is a function that returns true or false for each element, determining whether it should be included in the result. The most common approach is using LINQ's Where method, which applies a predicate function to filter elements. You can also use traditional loops or the Array.FindAll method for filtering. Syntax Following is the syntax for filtering with LINQ's Where method − IEnumerable result = array.Where(element => condition); Following is the syntax for filtering ...

Read More

How to define character constants in C#?

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

Character constants in C# are single characters enclosed in single quotes. They can be stored in variables of type char and represent individual characters, escape sequences, or Unicode characters. Syntax Following is the syntax for defining character constants − char variableName = 'character'; Character constants can be − Plain characters: 'a', 'X', '5' Escape sequences: '', '\t', ''' Unicode characters: '\u0041' (represents 'A') Common Character Constants Here are the most commonly used character escape sequences − Escape Sequence Character Description ...

Read More

How do you make code reusable in C#?

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

To make code reusable in C#, there are several key approaches including interfaces, inheritance, generic classes, and static methods. Among these, interfaces are particularly powerful as they define a contract that multiple classes can implement, enabling polymorphism and flexible code design. Interfaces define properties, methods, and events without providing implementations. The implementing classes must provide the actual functionality, ensuring a consistent structure across different implementations. Syntax Following is the syntax for declaring an interface − public interface IInterfaceName { void MethodName(); int PropertyName { get; set; } } ...

Read More

Decimal Functions in C#

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

The decimal data type in C# provides built-in methods for performing mathematical operations and comparisons on decimal values. These methods are essential for financial calculations and applications requiring high precision arithmetic. Common Decimal Methods Method Description Add(Decimal, Decimal) Adds two specified Decimal values. Ceiling(Decimal) Returns the smallest integral value that is greater than or equal to the specified decimal number. Compare(Decimal, Decimal) Compares two specified Decimal values. CompareTo(Decimal) Compares this instance to a specified Decimal object and returns a comparison of their relative values. ...

Read More

What is the System.Reflection.Module in C#?

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

The System.Reflection.Module class in C# represents a module, which is a portable executable file containing one or more classes and interfaces. It is part of the System.Reflection namespace that allows you to examine and manipulate metadata about types, assemblies, and modules at runtime. A module is essentially a single file within an assembly. Most .NET applications consist of a single module that matches the assembly, but complex applications can have multiple modules within one assembly. Key Properties and Methods The Module class provides several important properties and methods for reflection − Assembly − Gets the ...

Read More

What does the interface ICloneable do in C#?

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

The ICloneable interface in C# provides a mechanism to create a copy of an existing object, known as cloning. This interface is part of the System namespace and defines a standard way to duplicate objects. Syntax The ICloneable interface contains only one method − public interface ICloneable { object Clone(); } To implement ICloneable, a class must provide the Clone() method − public class MyClass : ICloneable { public object Clone() { // return a copy ...

Read More

C# Program to perform Currency Conversion

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

Currency conversion is a common programming task that involves multiplying an amount by an exchange rate. In C#, we can create simple currency conversion programs using basic arithmetic operations. A currency converter takes an amount in one currency and converts it to another currency using the current exchange rate. The formula is: Converted Amount = Original Amount × Exchange Rate. Syntax Following is the basic syntax for currency conversion − double convertedAmount = originalAmount * exchangeRate; Where variables are declared as − double originalAmount, convertedAmount, exchangeRate; Using Simple Currency ...

Read More

Multiple Access with Collision Avoidance (MACA)

Chandu yadav
Chandu yadav
Updated on 16-Mar-2026 5K+ Views

Multiple Access with Collision Avoidance (MACA) is a medium access control (MAC) layer protocol used in wireless networks to solve the hidden terminal problem and exposed terminal problem. The widely-used IEEE 802.11 RTS/CTS mechanism has been adopted from MACA. Working Principle The MACA protocol operates under the condition that stations are synchronized with identical frame sizes and data transmission speeds. It uses a four-way handshake involving RTS (Request to Send) and CTS (Clear to Send) frames before actual data transmission. Consider a transmitting station STA sending data to receiving station STB: Station STA sends an ...

Read More
Showing 131–140 of 810 articles
« Prev 1 12 13 14 15 16 81 Next »
Advertisements