## Differences: Static Class vs. Singleton Patterns

[ad_1] When producing apps with C# in the .Web framework, you have a preference concerning two single, shared class situations. No matter whether you make your mind up to use a static search phrase or a singleton design and style sample is dependent on numerous things, which are outlined in the report under.     … Read more

## Fibonacci Triangle in C Sharp

Fibonacci Triangle In C#, we can take input from the user for the limit for a Fibonacci triangle. The Fibonacci series can then be printed for that range or limit. Example: using System; public class Example { public static void Main(string[] args) { int x=1, y=2, i, z, num, j; Console.Write("Enter the range: "); num … Read more

Categories C#

## Number Triangle in C Sharp

Number Triangle There are several ways to print a number triangle in C#. Example: using System; public class Example { public static void Main(string[] args) { int x, y, z, w, num; Console.Write("Enter the Range: "); num = int.Parse(Console.ReadLine()); for(x=1; x<=num; x++) { for(y=1; y<=num-x; y++) { Console.Write(" "); } for(z=1; z<=x; z++) { Console.Write(z); … Read more

Categories C#

## Alphabet Triangle in C Sharp

Alphabet Triangle In C#, we can print two types of triangles, either generated by letters or numbers. Example: using System; public class Example { public static void Main(string[] args) { char ch = ‘a’; int x, y, z, w; for(x=1; x<=5; x++) { for(y=5; y>=x; y–) Console.Write(" "); for(z=1; z<=x; z++) Console.Write(ch++); ch–; for(w=1; w<x; … Read more

Categories C#

## Number in Characters in C Sharp

Number in Characters To convert a number in characters in C#, we can use a loop and switch case. After taking input from the user, the number is iterated and is divided by 10 until it becomes 0. The remainder so obtained is passed in switch case to retrieve the word for the number. Example: … Read more

Categories C#

## Decimal to Binary in C Sharp

Decimal to Binary A decimal or a base-10 number can be converted into binary or base-2 number in C#. Decimal Number: A decimal number ranges from 0 to 9. It can be any combination of the 10 digits between 0 to 9. Thus it is a base 10 number. Binary Number: A binary number is … Read more

Categories C#

## Swap Numbers in C Sharp

Swap Numbers In C#, we can swap two numbers without using a third variable, using either of the two ways: By using the + and – operators By using the * and / operators Example 1: Using ∗ and / operators. using System; public class Example { public static void Main(string[] args) { int x=20, … Read more

Categories C#

## Reverse number in C Sharp

Reverse number Loop and arithmetic operators can be used in C#, to reverse a number. Example: using System; public class Example { public static void Main(string[] args) { int num, rev=0, rem; Console.Write("Enter a Number: "); num = int.Parse(Console.ReadLine()); while(num!=0) { rem = num%10; rev = rev*10 + rem; num/=10; } Console.Write("Reverse of the Number: … Read more

Categories C#

## Sum of digits in C Sharp

Sum of digits We are using a loop and mathematical operations to print the sum of digits in C#. Algorithm: Step 1: Take input from the user. Step 2: The modulus/remainder of the number is then calculated. Step 3: The remainder of the number is then summed. Step 4: The number is then divided by … Read more

Categories C#

## Armstrong Number in C Sharp

Armstrong Number A number equal to the sum of the cubes of its digits is called an Armstrong number. For example, 0, 1, 153, 370, 371 and 407. Explanation: 153 = (1*1*1) + (5*5*5) + (3*3*3) = 1 + 125 + 27 = 153 Example: using System; public class Example { public static void Main(string[] … Read more

Categories C#