C# Program to Print the Sum of all the Multiples of 3 and 5

using System; namespace ConsoleApp2 { class Program { public static void Main() { int number, i, k, count = 1; Console.Write(“Enter number of rows\n”); number = int.Parse(Console.ReadLine()); count = number – 1; for (k = 1; k <= number; k++) { for (i = 1; i <= count; i++) Console.Write(” “); count–; for (i = […]

Read More

C# Program to Display Numbers in the form of Triangle

using System; class Pascal { public static void Main() { int[,] arr = new int[8, 8]; for (int i = 0; i < 8; i++) { for (int k = 7; k > i; k–) { //For loop to print spaces Console.Write(” “); } for (int j = 0; j < i; j++) { if […]

Read More

Count the frequency of each element of an array

In this program, we will count the frequency of each element of an array. Example: Elements in the array [1,8,4,2,8,1,4,8,9,8] Output: 1 occurs 2 times 8 occurs 4 times 4 occurs 2 times 2 occurs 1 times 9 occurs 1 times   using System; namespace ConsoleApp2 { class Program { static void Main(string[] args) { […]

Read More

Extension methods in C#

Extension methods are a new feature in C# 3.0. An extension method enables us to add methods to existing types without creating a new derived type, recompiling, or modify the original types. We can say that it extends the functionality of an existing type in .NET. An extension method is a static method to the […]

Read More