Articles on Trending Technologies

Technical articles with clear explanations and examples

DateTimeOffset.AddMonths() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 429 Views

The DateTimeOffset.AddMonths() method in C# is used to add a specified number of months to a DateTimeOffset instance. This method returns a new DateTimeOffset object with the month value adjusted while preserving the time zone offset information. Syntax Following is the syntax for the AddMonths() method − public DateTimeOffset AddMonths(int months); Parameters months − An integer representing the number of months to add. Use a positive value to add months or a negative value to subtract months. Return Value Returns a new DateTimeOffset object that represents the date and time that ...

Read More

C# program to count the occurrences of each character

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

Counting character occurrences in a string is a common programming task in C#. This can be accomplished using various approaches, from basic loops to modern LINQ methods and dictionary-based solutions. Using Basic Loop with String Manipulation The first approach uses a while loop and string replacement to count occurrences − using System; public class Demo { public static void Main() { string str = "Website"; Console.WriteLine("String: " + str); ...

Read More

What are the prerequisites for learning C#?

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

To start learning C#, you should have basic computer knowledge and familiarity with fundamental programming concepts. While prior experience with C or C++ is helpful, it is not mandatory − C# is beginner-friendly and can be your first programming language. Prerequisites Here are the essential prerequisites for learning C# − Basic Computer Skills: Understanding how to navigate files, folders, and install software. Programming Fundamentals: Basic knowledge of variables, loops, and conditional statements (helpful but not required). Mathematical Logic: Understanding of basic mathematical operations and logical thinking. Object-Oriented Concepts: Familiarity ...

Read More

Inbuilt Data Structures in C#

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

C# provides several powerful built-in data structures that make it easier to store, organize, and manipulate collections of data. These data structures are part of the .NET Framework and offer different capabilities for various programming scenarios. The most commonly used built-in data structures include List for dynamic arrays, ArrayList for non-generic collections, Dictionary for key-value pairs, and Queue and Stack for specialized ordering operations. List The generic List is a strongly-typed collection that can dynamically resize itself. Unlike arrays, you don't need to specify the size at compile time, and it provides better type safety compared to ...

Read More

How to input multiple values from user in one line in C#?

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

In C#, you can input multiple values from the user in one line using several approaches. The most common method is using Console.ReadLine() with Split() to parse space-separated or comma-separated values into an array. Syntax Following is the syntax for reading multiple values in one line using Split() − string input = Console.ReadLine(); string[] values = input.Split(' '); // or Split(', ') for comma-separated For converting to integers − int[] numbers = input.Split(' ').Select(int.Parse).ToArray(); Using Split() with Space Separator This approach reads a single line of space-separated values and ...

Read More

C# Program to find the largest element from an array

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

Finding the largest element in an array is a common programming task in C#. There are multiple approaches to achieve this, ranging from using built-in LINQ methods to implementing custom logic with loops. Using LINQ Max() Method The simplest approach is to use the Max() method from the System.Linq namespace − using System; using System.Linq; class Demo { static void Main() { int[] arr = { 20, 50, -35, 25, 60 }; int largest = ...

Read More

Implicit conversion from 32-bit unsigned integer (UInt) to Decimal in C#

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

Implicit conversion from a 32-bit unsigned integer (uint) to decimal in C# happens automatically when you assign a uint value to a decimal variable. This conversion is considered safe because decimal can represent all possible uint values without any loss of precision. Syntax Following is the syntax for implicit conversion from uint to decimal − uint uintValue = someValue; decimal decimalValue = uintValue; // implicit conversion How It Works The C# compiler automatically performs this conversion because: uint ranges from 0 to 4, 294, 967, 295 decimal can ...

Read More

What are the differences between constructors and destructors in C#?

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

A constructor is a special member function that initializes objects when they are created, while a destructor is called when an object goes out of scope or is garbage collected. Understanding the differences between these two fundamental concepts is essential for proper object lifecycle management in C#. Constructors A constructor is a special method that is automatically called when an object is created. It has the same name as the class and no return type. Syntax class ClassName { public ClassName() { // constructor code ...

Read More

C# program to check whether two sequences are the same or not

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

The SequenceEqual method in C# is a LINQ extension method that determines whether two sequences are equal by comparing their elements using the default equality comparer. It returns true if the sequences have the same length and corresponding elements are equal, otherwise it returns false. Syntax Following is the syntax for using SequenceEqual method − bool result = sequence1.SequenceEqual(sequence2); You can also use a custom equality comparer − bool result = sequence1.SequenceEqual(sequence2, comparer); Parameters sequence2 − The sequence to compare with the current sequence. comparer ...

Read More

C# Average Method

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

The Average() method in C# calculates the arithmetic mean of a sequence of numeric values. This method is part of LINQ (Language Integrated Query) and can be used with arrays, lists, and other enumerable collections. The Average() method has multiple overloads to work with different numeric types including int, double, decimal, float, and their nullable counterparts. Syntax Following is the basic syntax for the Average() method − public static double Average(this IEnumerable source) public static double Average(this IEnumerable source) public static decimal Average(this IEnumerable source) Parameters source − An enumerable ...

Read More
Showing 11091–11100 of 61,297 articles
Advertisements