Csharp Articles

Page 74 of 196

Convert a Character to the String in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 863 Views

Character manipulation is a common task in many programming applications. This article will guide you through the process of converting a character to a string in C#, an essential operation in various programming scenarios such as data parsing, formatting, and string building operations. Understanding Characters and Strings in C# Before we dive into the conversion process, let's first understand what characters and strings are in C#. A character (char) represents a single Unicode character and is denoted inside single quotes, while a string is a sequence of characters enclosed in double quotes. Character ...

Read More

Count the Number of Element Present in the Sequence in LINQ?

Siva Sai
Siva Sai
Updated on 17-Mar-2026 476 Views

Language Integrated Query (LINQ) is a powerful feature in C# that allows for efficient data manipulation. One common task when working with collections is determining the number of elements in a sequence. This article will guide you through using LINQ to count elements in various scenarios. Understanding LINQ Sequences A sequence in LINQ is any object that implements the IEnumerable or IEnumerable interface. This includes arrays, lists, collections, and query results. LINQ provides several methods to count elements efficiently. Syntax Following is the syntax for basic counting operations − // Count all elements int ...

Read More

Creating an Index From the Specified Index at the Start of a Collection in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 457 Views

In C#, manipulating collections is a frequent operation, with indexing being a crucial part of this process. The Index struct, introduced in C# 8.0, provides a powerful way to create indices that can represent positions from the start or end of a collection. This article will guide you through creating and using indices from specified positions at the start of collections in C#. Syntax Following is the syntax for creating an Index from the start of a collection − Index index = new Index(value, fromEnd: false); // OR using implicit conversion Index index = value; ...

Read More

Cross Join in LINQ

Siva Sai
Siva Sai
Updated on 17-Mar-2026 1K+ Views

Language Integrated Query (LINQ) is a powerful tool in C# for data manipulation, allowing for efficient and expressive data access and manipulation. One of the operations you can perform with LINQ is the cross join operation, which creates a Cartesian product between two data sources. Understanding Cross Join Cross join, also known as Cartesian product, is a type of join operation that matches each row of the first table with every row of the second table. If the first table has n rows and the second table has m rows, the result is a table with n×m rows. ...

Read More

Default Interface Methods in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 693 Views

Default interface methods are a game-changing feature introduced in C# 8.0 that allow developers to add new methods to an interface without breaking existing implementations. This feature enables interface evolution while maintaining backward compatibility with existing code. Syntax Following is the syntax for defining a default interface method − public interface IInterfaceName { void MethodName() { // default implementation } } A class can use the default implementation or override it − public class ClassName : IInterfaceName { ...

Read More

Checking if Two ValueTuple T1 are Equal or Not in C#

Siva Sai
Siva Sai
Updated on 17-Mar-2026 312 Views

ValueTuple in C# is a structure used to represent a data structure that can hold more than one value of differing types. Introduced in C# 7.0, ValueTuples are a significant improvement over classic tuples as they provide semantic names to the fields and better performance. This article demonstrates how to compare two instances of ValueTuple to check if they are equal. Understanding ValueTuple in C# ValueTuple is a value type representation of the Tuple class. Unlike reference-type Tuples, ValueTuples are stored on the stack and allow you to create tuples with named fields, making your code more readable ...

Read More

How to get only Date portion from DateTime object in C#?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 17-Mar-2026 66K+ Views

There are several ways to extract only the date portion from a DateTime object in C#. Each method serves different purposes depending on whether you need a string representation or want to preserve the DateTime type. Methods Overview Method Return Type Description ToShortDateString() String Returns culture-specific short date format ToLongDateString() String Returns culture-specific long date format ToString(format) String Returns custom formatted date string DateTime.Date DateTime Returns DateTime with time set to 00:00:00 Using ToShortDateString() and ToLongDateString() These methods provide culture-specific ...

Read More

C# program to calculate compound interest

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2026 5K+ Views

Compound interest is interest calculated on the initial principal amount plus all previously earned interest. Unlike simple interest, compound interest grows exponentially because the interest itself earns interest in subsequent periods. In this article, we will explore how to calculate compound interest using C#. What is Compound Interest? Compound Interest is the interest that calculates interest on both the initial principal and the accumulated interest from previous periods. This compounding effect causes the investment to grow at an accelerating rate over time. Compound Interest Growth Principal ...

Read More

C# Program to Find Prime Numbers Within a Range

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2026 4K+ Views

In this article, we are going to discuss how we can find prime numbers present within a given range using C#. What are Prime Numbers? Prime numbers are natural numbers greater than 1 that have exactly two factors − 1 and the number itself. They have no other positive divisors. Examples of prime numbers are 2, 3, 5, 7, 11, 13, 17, etc. Key Facts: The smallest prime number is 2, which is also the only even prime number. The number 1 is not a prime number because it has only one factor (itself). All ...

Read More

C# Program to Reverse a Number

AYUSH MISHRA
AYUSH MISHRA
Updated on 17-Mar-2026 7K+ Views

Reversing a number is a fundamental programming problem where we reverse the digits of an integer. For example, reversing 12345 gives 54321. This article explores different approaches to reverse a number in C#. Problem Description Given an integer, we need to reverse its digits and return the reversed number. The process involves extracting digits from right to left and reconstructing them from left to right. Examples Input: 12345 Output: 54321 Explanation: The digits are reversed from their original order. Input: 8299 Output: 9928 Explanation: The digits 8, 2, 9, 9 become 9, 9, 2, 8. ...

Read More
Showing 731–740 of 1,951 articles
« Prev 1 72 73 74 75 76 196 Next »
Advertisements