Programming Articles

Page 798 of 2547

C# program to implement FizzBuzz

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

The FizzBuzz problem is a classic programming exercise that involves printing numbers from 1 to 100 with specific replacements. If a number is divisible by 3, print "Fizz". If divisible by 5, print "Buzz". If divisible by both 3 and 5, print "FizzBuzz". Otherwise, print the number itself. This problem tests your understanding of conditional statements, loops, and the modulo operator in C#. Syntax The modulo operator % is used to check divisibility − if (number % divisor == 0) { // number is divisible by divisor } The logical ...

Read More

CharEnumerator.Clone() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 145 Views

The CharEnumerator.Clone() method in C# is used to create a copy of the current CharEnumerator object. This method returns an object that must be cast to CharEnumerator to use its functionality. The cloned enumerator maintains the same position as the original enumerator at the time of cloning. Syntax public object Clone(); Return Value Returns an object that is a copy of the current CharEnumerator instance. The returned object must be cast to CharEnumerator to access enumerator-specific methods. Using CharEnumerator.Clone() The following example demonstrates how to create and use a cloned CharEnumerator − ...

Read More

UInt64.ToString() Method in C# with Examples

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 551 Views

The UInt64.ToString() method in C# is used to convert the numeric value of the current UInt64 instance to its equivalent string representation. This method is particularly useful when you need to display UInt64 values as text or perform string operations on numeric data. Syntax Following is the syntax for the parameterless overload − public override string ToString(); The method also has additional overloads for custom formatting − public string ToString(string format); public string ToString(IFormatProvider provider); public string ToString(string format, IFormatProvider provider); Return Value Returns a string that represents the ...

Read More

What are different methods of passing parameters in C#?

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

When a method with parameters is called, you need to pass the parameters to the method using one of the following three methods in C# − Value Parameters (Default) This method copies the actual value of an argument into the formal parameter of the function. Changes made to the parameter inside the function have no effect on the original argument because the method works with a copy of the value. Value Parameters - Copy by Value Main Method int a = 7 int b ...

Read More

What are string literals in C#?

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

String literals in C# are constant string values enclosed in double quotes "" or prefixed with @"" for verbatim strings. A string literal contains characters that can include plain text, escape sequences, and Unicode characters. Types of String Literals C# supports several types of string literals − Regular String Literals: Enclosed in double quotes with escape sequences Verbatim String Literals: Prefixed with @ symbol, allowing multi-line strings and literal backslashes Raw String Literals: (C# 11+) Use triple quotes """ for complex strings Syntax Following are the different syntaxes for string literals − ...

Read More

Overloaded method and ambiguity in C#

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

With method overloading, you can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. However, when using default parameters with overloaded methods, ambiguity can occur if the compiler cannot determine which method to call. Syntax Following is the syntax for method overloading − public void MethodName(int parameter1) { // Implementation 1 } public void MethodName(int parameter1, int parameter2) { // Implementation 2 ...

Read More

Sort the words in lexicographical order in C#

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

Lexicographical order means sorting strings alphabetically, similar to how words are arranged in a dictionary. In C#, there are multiple ways to sort an array of strings in lexicographical order using built-in methods and LINQ. Syntax Using LINQ query syntax − var sorted = from word in array orderby word select word; Using Array.Sort() method − Array.Sort(array); Using LINQ OrderBy() method − ...

Read More

C# program to copy a range of bytes from one array to another

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

The Buffer.BlockCopy method in C# is used to copy a range of bytes from one array to another. This method provides a fast, low-level approach for copying data between arrays and is particularly useful when working with byte arrays or when you need to copy a specific range of elements. Syntax Following is the syntax for the Buffer.BlockCopy method − Buffer.BlockCopy(sourceArray, sourceOffset, destinationArray, destinationOffset, count); Parameters sourceArray − The source array from which to copy bytes sourceOffset − The zero-based byte offset into the source array destinationArray − The destination array to ...

Read More

Represent Int32 as a Hexadecimal String in C#

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

To represent Int32 as a hexadecimal string in C#, you can use several methods. The most common approaches are using Convert.ToString() with base 16, or using the ToString() method with hexadecimal format specifiers. Int32 represents a 32-bit signed integer that can hold values from -2, 147, 483, 648 to 2, 147, 483, 647. Converting these values to hexadecimal format is useful for debugging, display purposes, and when working with low-level operations. Using Convert.ToString() with Base 16 The Convert.ToString() method accepts a base parameter. Setting it to 16 converts the integer to its hexadecimal representation − ...

Read More

How to create an infinite loop in C#?

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

An infinite loop is a loop that never terminates and repeats indefinitely. While infinite loops are generally undesirable in most applications, they can be useful in specific scenarios like game loops, server applications, or continuous monitoring systems. There are several ways to create infinite loops in C#, each with different syntax and use cases. Using For Loop The most common way to create an infinite loop is by manipulating the loop condition so it never becomes false − using System; class Program { static void Main(string[] args) { ...

Read More
Showing 7971–7980 of 25,466 articles
« Prev 1 796 797 798 799 800 2547 Next »
Advertisements